I have been meaning to look into a solution for restarting Laravel Horizon on code changes for a while. Our team uses Docker for our development environment and a container will start with horizon running. However, any code changes would mean we had to restart that container before the changes would load.
That's when I looked into a solution. It turns out it was pretty simple. There is a handy node tool that will monitor files for changes and restart. I have seen it in use for simple nodejs servers. Enter nodemon
We can install it in an Ubuntu container with
apt-get update && apt-get install npm -y && npm install -g nodemon
Now we launch our horizon with the below command
/usr/local/bin/nodemon --exec /usr/local/bin/php artisan horizon -e php
the -e php
tells nodemon to monitor all .php
files and restart on a change.
Top comments (0)