alright, everybody writen one about this but nothing worked for me, here's how it works without any problem:
first run brew install supervisor
run brew services start supervisor
now to start supervisor, this will make sure supervisor runs at startup as well.
supervisor searches for configuration file in following paths: /usr/local/etc/supervisord.conf, /usr/local/supervisord.conf, supervisord.conf, etc/supervisord.conf, /etc/supervisord.conf, /etc/supervisor/supervisord.conf
we have to create one in order for it to work:
echo_supervisord_conf > /usr/local/etc/supervisord.conf
now default configuration is set, we need to create the following directory so supervisor can look for your configuration files:
mkdir /usr/local/etc/supervisor.d
now create your supervisor configuration file in the directory we just created:
vi /usr/local/etc/supervisor.d/your_app_conf.ini
paste your configuration:
[program:pezhvak-ai-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/Users/pezhvak/Sites/pezhvak.space
command=php artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=pezhvak
numprocs=8
redirect_stderr=true
stdout_logfile=~/sites/pezhvak.space/storage/logs/worker.log
** Note: directory should be set in full path, it does not recognize ~ as home direectory somehow **
and now you need to inform supervisor to reload configurations and start workers:
supervisorctl reread
supervisorctl update
supervisorctl start all
if anything goes wrong you can check the log files in the 'stdout_logfile' you specified.
to check status of your workers you can run supervisorctl status
All done, enjoy.
*** NOTE ***
everytime you update your laravel application, or .env file, you need to restart your workers for changes to take effect:
supervisorctl restart all