DEV Community

Cover image for Auto restarting Laravel Horizon on code changes
Stev Lasowski
Stev Lasowski

Posted on • Edited on

1

Auto restarting Laravel Horizon on code changes

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
Enter fullscreen mode Exit fullscreen mode

Now we launch our horizon with the below command

/usr/local/bin/nodemon --exec /usr/local/bin/php artisan horizon -e php
Enter fullscreen mode Exit fullscreen mode

the -e php tells nodemon to monitor all .php files and restart on a change.

Buy Me A Coffee

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

👋 Kindness is contagious

If this post resonated with you, feel free to hit ❤️ or leave a quick comment to share your thoughts!

Okay