- Notifications
You must be signed in to change notification settings - Fork4
A modern solution for running Laravel Horizon with a CRON-based supervisor.
License
ralphjsmit/laravel-horizon-cron-supervisor
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Run Laravel Horizon on cheap hosting environments without Supervisor🤑
This Laravel package automatically checks every three minutes if yourLaravel Horizon instance is still running. In that way, it is the perfect replacement for the normally recommendedSupervisor Process Control System, for which you need your own server.
This package allows running Laravel Horizon on shared hosting instances and servers where you don't have to option to install Supervisor.
Under the hood, the package automatically schedules a simple Artisan command to run every three minutes that checks whether Horizon is still running. If not, it'll restart the Horizon queues.
Run the following command to install the package:
composer require ralphjsmit/laravel-horizon-cron-supervisor
The package works without any configuration.Note that you need to have the Laravel Scheduler configured correctly.
You can publish the config file or just use the environment variables.
php artisan vendor:publish --tag="horizon-cron-supervisor-config"
The config file contents.
<?phpreturn [/** * Enables Horizon Cron Supervisor */'enabled' =>env('HORIZON_CRON_SUPERVISOR_ENABLED',true),/** * Run every X minutes or define a cron expression like "0,20,40 * * * *" */'schedule' =>env('HORIZON_CRON_SUPERVISOR_SCHEDULE',3),];
When you deploy a new version of your app, you usually shut down your queues and Horizon instances in order let them use the files. The Laravel Scheduler doesn't run any commands when your application is inmaintenance mode (php artisan down
). Thus as long as your application is in maintenance mode, you don't need to worry about this package restarting your queues when you don't want that.
A typical deployment workflow could look something like this:
# Prepare deploymentphp artisan downphp artisan horizon:terminate# Do deployment logic# Horizon will not be restarted until you put the application out of maintenance modephp artisan horizonphp artisan up# Finish up deployment
Note that this workflow is greatly simplified and doesn't take into account anything specific to your server or running commands like your migrations.
This package was created byRalph J. Smit. Checkout my websiteralphjsmit.com forLaravel and development-related tutorials.
The package was inspired bythis StackOverflow question and my need for this as well. Special thanks toahoffman for his code on running and checking whether Horizon is active.
About
A modern solution for running Laravel Horizon with a CRON-based supervisor.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.