Run Horizon by Supervisord in Laradock

Laradock needs to be set up to work with Supervisor. Here is how to Run Horizon by Supervisord in Laradock .

 

Supervisord Configuration

To Run Horizon by supervisord in Laradock you have to add horizon.conf to php-worker/supervisord.d/horizon.conf with the following content

[program:horizon]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/laravel/artisan horizon
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true

Adding Queue Worker

Had an issue that the job would just stay paused. Had to add a worker queue using:

php artisan queue:work --queue=ssl-manager -- redis

You can however also add this queue to supervisord as another config:

[program:ssl-manager]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/laravel/artisan queue:work --queue=ssl-manager -- redis
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true

then you can restart the docker using

docker-compose restart php-worker

Supervisord Changes

Also to make supervisor check for changes check into your php worker using

docker-compose exec php-worker ash

and use:

supervisorctl reread

This so it is made aware of the new config. Then you can use

supervisorctl update

to update supervisor on your changes.

NB To check existing config files check out the config files under the directory supervisor:

root@site-staging:/etc/supervisor/conf.d# ll
total 20
drwxr-xr-x 2 root root 4096 Mar 19 08:05 ./
drwxr-xr-x 3 root root 4096 Jun 19  2018 ../
-rw-r--r-- 1 root root  282 Mar 19 08:05 daemon-111.conf
-rw-r--r-- 1 root root  277 Mar  2 02:53 daemon-222.conf
-rw-r--r-- 1 root root  309 Mar 13 09:32 daemon-333.conf
Tagged in : Tagged in : ,
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.