← Other topics

Forge Under the Hood - Daemons (Supervisor)

Video Notes

Let’s learn what Forge is doing on your server with its Daemons feature. You can use this information when troubleshooting or if you decide to cancel your Forge subscription and manage your own servers.

Daemon = Supervisor

Forge uses the Supervisor process control system to manage and monitor daemons. Daemons are used to keep long-running scripts alive on your server. For example, if you’re using Laravel queues, you’ll want a daemon to run the command php artisan queue:work.

Configs

Every daemon you create in Forge is saved as a config file /etc/supervisor/conf.d.

For example, in Forge I have the following daemon:

And here is its corresponding config file from /etc/supervisor/conf.d/daemon-677951.conf

> cat /etc/supervisor/conf.d/daemon-677951.conf
[program:daemon-677951]
directory=/home/forge/courseintros.com/
command=php artisan queue:work --tries=1 --timeout=360

process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
user=forge
numprocs=1
startsecs=1
redirect_stderr=true
stdout_logfile=/home/forge/.forge/daemon-677951.log
stopwaitsecs=10
stopsignal=SIGTERM
stopasgroup=true
killasgroup=true

After making any changes to the daemon config files, reload the Supervisor configuration for the changes to take effect with the following two commands:

> sudo supervisorctl reread
> sudo supervisorctl update

If you plan on continuing to use Forge to manage your servers, do not make manual changes to your daemon config files on the server as Forge notes this can cause things to become out of sync:

Status commands

To see the status of all daemons run:

> sudo supervisorctl status

The process name is the full name you see when running sudo supervisorctl status. E.g., for this output:

daemon-677951:daemon-677951_00   RUNNING   pid 4094966, uptime 75 days, 23:44:34

The process name is daemon-677951:daemon-677951_00

To see status of a specific daemon:

> sudo supervisorctl status daemon-677951:daemon-677951_00

Logs

Daemon logs are located in /home/forge/.forge

Resources

If this info helped you out, you can send a tip via PayPal. Thanks for your support!
← Other topics