# 🚨 CORREÇÃO DEFINITIVA - ERRO 503

## Execute no Servidor

```bash
cd /var/www/gestorstream/backend

# Opção 1: Script PHP completo (RECOMENDADO)
php fix-503-complete.php

# Opção 2: Script bash
chmod +x fix-503-definitive.sh
bash fix-503-definitive.sh

# Opção 3: Teste direto
php test-503-direct.php
```

## Se Ainda Não Funcionar

### 1. Verificar Logs do Laravel

```bash
tail -100 storage/logs/laravel.log | grep -i "error\|exception\|503"
```

### 2. Verificar se há erro de sintaxe

```bash
php -l bootstrap/app.php
php -l public/index.php
php -l routes/api.php
```

### 3. Verificar cache do banco de dados

```bash
php artisan tinker
>>> \Illuminate\Support\Facades\Cache::flush();
>>> \Illuminate\Support\Facades\DB::table('cache')->where('key', 'like', '%maintenance%')->delete();
>>> exit
```

### 4. Verificar configuração do Nginx

```bash
# Verificar se há redirect ou proxy que pode estar causando 503
grep -r "503\|maintenance" /etc/nginx/sites-enabled/
```

### 5. Testar diretamente o PHP-FPM

```bash
# Criar arquivo de teste
echo '<?php phpinfo(); ?>' > /var/www/gestorstream/backend/public/test.php

# Testar
curl https://gestor.jf.eng.br/test.php

# Se funcionar, o problema é no Laravel
# Se não funcionar, o problema é no PHP-FPM/Nginx
```

### 6. Verificar se há processo travado

```bash
ps aux | grep php-fpm
ps aux | grep nginx

# Se houver processos travados, reiniciar
systemctl restart php8.2-fpm
systemctl restart nginx
```

## Solução de Último Recurso

Se nada funcionar, pode ser um problema com o cache do OPcache:

```bash
# Limpar OPcache
php -r "opcache_reset();"

# Ou reiniciar PHP-FPM (limpa OPcache automaticamente)
systemctl restart php8.2-fpm
```

