Run PHP Script as Daemon Using Supervisord
This short post is just a reminder for myself when writing supervisord configuration files, it’s extremely useful for running daemon workers (such as Laravel’s queue workers). You’ll need the supervisor
Ubuntu package installed.
Create a file at /etc/supervisor/conf.d/bob-program.conf
and enter the file contents:
[program:bob-worker]
command=php /home/bob/worker.php
autostart=true
autorestart=true
user=bob
redirect_stderr=true
stdout_logfile=/home/bob/logs/worker.log
Then restart supervisor with service supervisor restart
and your program should launch.