Skip to content

Instantly share code, notes, and snippets.

@azimidev
Forked from danharper/a.md
Last active November 15, 2022 14:42
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save azimidev/f81e0c74a7574cee94f77f5df9389d77 to your computer and use it in GitHub Desktop.
Save azimidev/f81e0c74a7574cee94f77f5df9389d77 to your computer and use it in GitHub Desktop.
Laravel Queue Supervisor

Install Supervisor with sudo apt-get install supervisor in Unix or brew install supervisor in Mac OSX. Ensure it's started with sudo service supervisor restart in Unix or brew services start supervisor in Mac OSX.

In Unix in /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

In Mac OSX first run supervisord -c /usr/local/etc/supervisord.ini and in /usr/local/etc/supervisor.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread in Unix and with: brew services restart supervisor in MAc OSX . And start using those changes with: sudo supervisorctl update.

Now run your supervisor queues by run_queue.sh.

[program:laravel_queue]
command=/usr/local/bin/run_queue.sh
autostart=true
autorestart=true
stderr_logfile=/var/log/laraqueue.err.log
stdout_logfile=/var/log/laraqueue.out.log
#!/bin/bash
php /path/to/AppName/artisan --env=production --timeout=240 queue:listen
@adibnoh
Copy link

adibnoh commented Apr 21, 2017

Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/local/bin/supervisord -h

I got this error when try to run

supervisord -c /usr/local/etc/supervisord.ini

@Krato
Copy link

Krato commented Aug 29, 2017

@adibnoh just stop supervisor brew services stop supervisor, and try again. Remember to start the service again.

@vesper8
Copy link

vesper8 commented Sep 4, 2017

I had some trouble getting this to work on OSX Sierra

First, I had to create the supervisor.d folder

Then I kept having errors when trying to use supervisorctl. The solution was to use -c with supervisorctl too (not only supervisord)

Lastly I noticed that the default configuration file when using brew install supervisor is supervisord.ini (not .conf) and in it it auto-includes .ini files (not .conf)

all is working now. I made myself these two bash aliases to make it easier

alias resup="sudo supervisorctl -c /usr/local/etc/supervisord.ini reread && sudo supervisorctl -c /usr/local/etc/supervisord.ini update"
alias supconf="open /usr/local/etc/supervisor.d"

update: the next day I started having some very weird problems with Horizon and Supervisor. Horizon would start but it would show nothing under supervisors and wouldn't process my queues. But if I started it manually it worked.

After trying a few things I gave up on using brew to manage (start/stop/restart) and wrote this little function which seems to work every time now

resup() {
    local configFile="/usr/local/etc/supervisord.ini"
    eval "sudo supervisorctl -c ${configFile} shutdown"
    eval "sudo supervisord -c ${configFile}"
    eval "sudo supervisorctl -c ${configFile} reread"
    eval "sudo supervisorctl -c ${configFile} update"
}

@chiragck
Copy link

error: <class 'socket.error'>, [Errno 61] Connection refused: file: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py line: 575
i got this error when try to run
sudo supervisorctl update

@IgnacioYanjari
Copy link

error: <class 'socket.error'>, [Errno 61] Connection refused: file: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py line: 575
i got this error when try to run
sudo supervisorctl update

i solved that problem run before sudo supervisord

@IgnacioYanjari
Copy link

i got a problem, when i run sudo supervisorctl -c /usr/local/etc/supervisord.ini reread doesnt load the new config !! 😞

@eddiechok
Copy link

i got a problem, when i run sudo supervisorctl -c /usr/local/etc/supervisord.ini reread doesnt load the new config !!

Originally the /usr/local/etc/supervisord.ini file only includes all the files in /usr/local/etc/supervisor.d. Changed it to include *.conf and it should work.

@aspyropoulos
Copy link

aspyropoulos commented Nov 7, 2022

Is this still valid? when I am running sudo supervisorctl -c /usr/local/etc/supervisord.ini I am getting
Error: could not find config file /usr/local/etc/supervisord.ini. Where/how can I locate the supervisord.ini?

@marfrede
Copy link

Is this still valid? when I am running sudo supervisorctl -c /usr/local/etc/supervisord.ini I am getting Error: could not find config file /usr/local/etc/supervisord.ini. Where/how can I locate the supervisord.ini?

same for me @aspyropoulos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment