Skip to content

Instantly share code, notes, and snippets.

@Pezhvak
Last active November 15, 2023 13:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pezhvak/297b058d9c449b39d321409cd041899c to your computer and use it in GitHub Desktop.
Save Pezhvak/297b058d9c449b39d321409cd041899c to your computer and use it in GitHub Desktop.
Supervisor Mac Installation (Laravel)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment