ubuntu ~ $ sudo apt install supervisor
Check that it's running successfully after installation:
ubuntu ~ $ service supervisor status is running
ubuntu ~ $ sudo groupadd supervisor
ubuntu ~ $ sudo usermod -a -G supervisor ubuntu
Here is the complete
; supervisor config file [unix_http_server] file=/var/run/supervisor.sock ; (the path to the socket file) chmod=0770 ; sockef file mode (default 0700) chown=root:supervisor [supervisord] logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket ; The [include] section can just contain the "files" setting. This ; setting can list multiple files (separated by whitespace or ; newlines). It can also contain wildcards. The filenames are ; interpreted as relative to this file. Included files *cannot* ; include files themselves. [include] files = /etc/supervisor/conf.d/*.conf
[unix_http_server] section we can see the adjusted
chmod=0770 directive which will assign group write permissions for for the socket file, along with the
chown=root:supervisor line which will adjust the group of the socket file to our newly created
Reload the process after adjusting the config file:
sudo service supervisor restart Restarting supervisor: supervisord.
In this example we'll control a Laravel queue; here is the configuration file in
[program:queue] process_name=%(program_name)s_%(process_num)02d command=sudo php /var/www/laravel/artisan queue:work --tries=3 --daemon --queue=test -vvv user=root autostart=true autorestart=true numprocs=1 redirect_stderr=true stdout_logfile=/var/www/laravel/storage/logs/test.log
command variable tells supervisor which command to run, in our case an artisan command to work on a specific Laravel queue. The
stdout_logfile adds a log file to Laravel's log directory.
reread supervisor command to make supervisor aware of the new program configuration file we've just created, and then use the
update command to apply the changes:
ubuntu ~ $ supervisorctl reread queue: changed ubuntu ~ $ supervisorctl update ubuntu ~ $ supervisorctl status queue:queue_00 RUNNING pid 18494, uptime 0:00:02
Knowledge Base is a repository for various notes, guides, and thoughts on a wide range of IT related topics. Read more...
Web development services by Say Web Solutions. Visit website.