148 lines
4.0 KiB
Markdown
148 lines
4.0 KiB
Markdown
# Incident Runbook - 2026-03-09
|
|
|
|
## Titolo
|
|
|
|
500 in produzione e sviluppo: permessi `laravel.log` + parse error Filament.
|
|
|
|
## Sintomi Osservati
|
|
|
|
- Produzione: `UnexpectedValueException` su `vendor/monolog/.../StreamHandler.php`.
|
|
- Messaggio: `The stream or file "/var/www/netgescon/storage/logs/laravel.log" could not be opened in append mode: Permission denied`.
|
|
- Sviluppo: `500 Internal Server Error` su `http://192.168.0.200:8000/admin-filament`.
|
|
|
|
## Cause Radice
|
|
|
|
1. **Produzione - log non scrivibile dal web server**
|
|
|
|
- File: `/var/www/netgescon/storage/logs/laravel.log`
|
|
- Stato trovato: owner/group `michele:michele`, mode `775`.
|
|
- Processo web: `nginx` con utente/gruppo `www-data`.
|
|
- Effetto: Monolog non riesce ad aprire il log in append.
|
|
|
|
1. **Sviluppo - errore sintattico PHP**
|
|
|
|
- File 1: `app/Providers/Filament/AdminFilamentPanelProvider.php`
|
|
- Problema: catena fluent Filament spezzata da parentesi/brace errate.
|
|
- File 2: `app/Filament/Pages/Condomini/NominativiStabile.php` (linea area ~436).
|
|
- Problema: concatenazione stringa SQL spezzata (`.` fuori espressione).
|
|
|
|
## Fix Applicati
|
|
|
|
### A) Permessi Log Produzione
|
|
|
|
Comandi eseguiti:
|
|
|
|
```bash
|
|
chgrp www-data /var/www/netgescon/storage/logs/laravel.log
|
|
chmod 664 /var/www/netgescon/storage/logs/laravel.log
|
|
find /var/www/netgescon/storage/logs -maxdepth 1 -type f -name '*.log' -exec chgrp www-data {} \; -exec chmod 664 {} \;
|
|
```
|
|
|
|
Esito atteso:
|
|
|
|
- `laravel.log` in `michele:www-data` con permessi `-rw-rw-r--`.
|
|
|
|
### B) Parse Error Sviluppo
|
|
|
|
- Ripristinata sintassi valida in:
|
|
- `app/Providers/Filament/AdminFilamentPanelProvider.php`
|
|
- `app/Filament/Pages/Condomini/NominativiStabile.php`
|
|
|
|
Verifica:
|
|
|
|
```bash
|
|
php -l app/Providers/Filament/AdminFilamentPanelProvider.php
|
|
php -l app/Filament/Pages/Condomini/NominativiStabile.php
|
|
php artisan about
|
|
```
|
|
|
|
Esito ottenuto:
|
|
|
|
- `No syntax errors detected` sui file.
|
|
- `php artisan about` torna operativo.
|
|
|
|
### C) Allineamento Produzione
|
|
|
|
File copiati da sviluppo a produzione:
|
|
|
|
- `app/Providers/Filament/AdminFilamentPanelProvider.php`
|
|
- `app/Filament/Pages/Condomini/NominativiStabile.php`
|
|
|
|
Pulizia cache:
|
|
|
|
```bash
|
|
cd /var/www/netgescon
|
|
php artisan optimize:clear
|
|
```
|
|
|
|
## Check Rapido Post-Incident
|
|
|
|
1. Verifica sintassi:
|
|
|
|
```bash
|
|
cd /home/michele/netgescon/netgescon-laravel
|
|
php -l app/Providers/Filament/AdminFilamentPanelProvider.php
|
|
php -l app/Filament/Pages/Condomini/NominativiStabile.php
|
|
```
|
|
|
|
1. Verifica bootstrap Laravel (sviluppo):
|
|
|
|
```bash
|
|
php artisan about
|
|
```
|
|
|
|
1. Verifica endpoint sviluppo:
|
|
|
|
```bash
|
|
curl -I http://192.168.0.200:8000/admin-filament
|
|
```
|
|
|
|
Atteso: `302` verso login (non `500`).
|
|
|
|
1. Verifica log produzione:
|
|
|
|
```bash
|
|
ls -l /var/www/netgescon/storage/logs/laravel.log
|
|
```
|
|
|
|
Atteso: gruppo `www-data` e write abilitata al gruppo.
|
|
|
|
## Procedura Di Ripartenza Veloce (Se "Salta Tutto")
|
|
|
|
1. Correggi permessi `storage`/`cache` su produzione:
|
|
|
|
```bash
|
|
chgrp -R www-data /var/www/netgescon/storage /var/www/netgescon/bootstrap/cache
|
|
find /var/www/netgescon/storage -type d -exec chmod 2775 {} \;
|
|
find /var/www/netgescon/storage -type f -exec chmod 664 {} \;
|
|
find /var/www/netgescon/bootstrap/cache -type d -exec chmod 2775 {} \;
|
|
find /var/www/netgescon/bootstrap/cache -type f -exec chmod 664 {} \;
|
|
```
|
|
|
|
1. Riallinea file critici da sorgente:
|
|
|
|
```bash
|
|
cp /home/michele/netgescon/netgescon-laravel/app/Providers/Filament/AdminFilamentPanelProvider.php /var/www/netgescon/app/Providers/Filament/AdminFilamentPanelProvider.php
|
|
cp /home/michele/netgescon/netgescon-laravel/app/Filament/Pages/Condomini/NominativiStabile.php /var/www/netgescon/app/Filament/Pages/Condomini/NominativiStabile.php
|
|
```
|
|
|
|
1. Pulisci cache Laravel:
|
|
|
|
```bash
|
|
cd /var/www/netgescon
|
|
php artisan optimize:clear
|
|
```
|
|
|
|
1. Verifica endpoint e log:
|
|
|
|
```bash
|
|
curl -I http://192.168.0.200:8000/admin-filament
|
|
ls -l /var/www/netgescon/storage/logs/laravel.log
|
|
```
|
|
|
|
## Note Preventive
|
|
|
|
- Evitare copy/sync che riscrivono ownership in `storage/logs`.
|
|
- Dopo hotfix su file PHP, eseguire sempre `php -l` prima del deploy.
|
|
- Se compare 500 su Filament, fare subito `php artisan about` per intercettare parse error in bootstrap.
|