Skip to content

Instantly share code, notes, and snippets.

@abhi-nav
Last active August 14, 2018 09:23
Show Gist options
  • Save abhi-nav/fd9d17bc21b3ac6c22746458248519de to your computer and use it in GitHub Desktop.
Save abhi-nav/fd9d17bc21b3ac6c22746458248519de to your computer and use it in GitHub Desktop.
Multi Thread Job Handler in Laravel or any other application

Installation guide on MAC

Can be configured in any OS similary

Install Supervisor Package with brew install supervisor or see Installation Guide for any other OS.

Once installed this will create supervisord.ini file in /usr/local/etc which is a config file

Rename this file to supervisord.conf so that we can start supervisor with command supervisorctl -c /usr/local/etc/supervisord.conf (by default supervisor creates supervisord.ini which throws error should be conf file)

I have generated 50 processes to execute queued job in laravel application, Ofcourse you can use to trigger any other application interface other than laravel

Now create your own conf file that will start non-daemonized processes for eg. laravel_queue.conf in the directory /usr/local/etc/supervisor.d/

Dont forget to include your conf file in supervisord.conf at last

[include]
files = /usr/local/etc/supervisor.d/*.ini

Now execute command to initialise

  • supervisorctl -c /usr/local/etc/supervisord.conf
  • supervisord -c /usr/local/etc/supervisord.conf

Now you can control supervisor task by command supervisorctl which will show all the running task and different options ☺️

[program:laravel-queue]
command=php /Library/WebServer/Documents/otest/artisan queue:work --tries=2
autostart=true
process_name=%(program_name)s_%(process_num)02d
autorestart=true
numprocs=50
stderr_logfile=/var/log/laravel-queue/laraqueue.err.log
stdout_logfile=/var/log/laravel-queue/laraqueue.out.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment