TLDR; Managing Laravel Queues with Supervisor and Debian 8

Steve Clifton
2 min readAug 30, 2018

Supervisor is a super handy process control system that we can use to send emails out for our application. There are literally (ok, figuratively) tons of other use cases for supervisor, but my current focus is to get all my emails sending out automatically.

FIRST STEP: Clear your queues, unless you want all your emails to go out once this is completed. Don’t make the mistake of queuing up thousands of test emails to all sorts of random email addresses you might have used at some points in testing, thinking they would be discarded at some point, but end up spamming them out to poor unsuspecting folk.. DELETE them first

  1. Next first step is to install supervisor,
sudo apt-get install supervisor

2. Once successfully installed, we need to create our configuration file telling supervisor what we want it to do. Lets create a new file like below,

sudo vi /etc/supervisor/conf.d/project_name-emails.conf

3. The config file can have a ton of variables, which can be further explored HERE, but as this article is a tldr version, the basic stuff we need is below

[program:project_name-emails]# The command that will be run when this program is started
command=php artisan queue:work --tries=3 --sleep=3
# File path supervisor goes to before executing above
directory=/var/www/project_name
# Log files
stdout_logfile=/var/www/project_name/storage/logs/supervisord.log
# stderrors piped back to supervisor daemon
redirect_stderr=true
# Start automatically
autostart=true
# Restart automatically
autorestart=true

Once setup, simply use the below and we should be up and running.

systemctl restart supervisor

--

--