[Unit] Description=c4rgo scanner MQTT listener (Symfony worker app:scanner:listener) Documentation=file://__DEPLOY_PATH__/docker/mqtt/README.md # Il worker ha bisogno di rete, del broker e del DB. After=network-online.target mosquitto.service mysql.service Wants=network-online.target Requires=mosquitto.service [Service] Type=simple # Utente/gruppo con cui gira l'app (es. www-data). Deve poter leggere il codice # e .env.local, e scrivere var/ (cache/log) del progetto. User=__RUN_USER__ Group=__RUN_USER__ WorkingDirectory=__DEPLOY_PATH__ Environment=APP_ENV=prod # -d = loop infinito in foreground (NON fa fork): systemd gestisce il processo. ExecStart=__PHP_BIN__ bin/console app:scanner:listener -d # Il comando esce con FAILURE se l'EntityManager si chiude: farlo ripartire. Restart=always RestartSec=5 # Stop pulito: il comando intercetta SIGTERM e chiude la connessione MQTT. KillSignal=SIGTERM TimeoutStopSec=15 # Hardening opzionale (scommenta se compatibile col tuo layout): #NoNewPrivileges=true #ProtectSystem=full #PrivateTmp=true [Install] WantedBy=multi-user.target