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

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay