huangdijia/laravel-horizon-restart
| Install | |
|---|---|
composer require huangdijia/laravel-horizon-restart |
|
| Latest Version: | v3.1.0 |
| PHP: | >=8.1 |
| License: | MIT |
| Last Updated: | Mar 5, 2026 |
| Links: | GitHub · Packagist |
Laravel Horizon Restart
A Laravel package that extends Laravel Horizon with the ability to restart supervisors across multiple servers, similar to php artisan queue:restart but specifically designed for Horizon workers.
Features
- 🚀 Restart all Horizon supervisors across multiple servers with a single command
- 🔄 Graceful termination of workers similar to
queue:restart - 📦 Automatic service provider registration
- 🎯 Works seamlessly with Horizon's queue distribution
- ⚡ Zero downtime deployments for Horizon workers
Requirements
- PHP 8.2 or higher
- Laravel 11.x or 12.x
- Laravel Horizon 5.x or 6.x
Installation
Install the package via Composer:
composer require huangdijia/laravel-horizon-restart
The service provider will be automatically registered.
Usage
Basic Usage
To restart all Horizon supervisors across all servers:
php artisan horizon:restart
This command will:
- Discover all running Horizon supervisors
- Dispatch a restart job to each supervisor's queue
- Gracefully terminate each supervisor (similar to
horizon:terminate) - Horizon will automatically restart the supervisors
How It Works
When you run horizon:restart, the package:
- Discovers Supervisors: Queries the Horizon master supervisor repository to find all active supervisors
- Dispatches Jobs: Creates a
HorizonRestartJobfor each supervisor and dispatches it to that supervisor's queue - Executes Termination: Each job runs on its respective server and calls
horizon:terminatelocally - Auto Restart: Horizon's process monitoring automatically restarts terminated supervisors
This approach ensures that:
- All servers receive the restart signal
- Workers finish their current jobs before terminating
- No jobs are lost during the restart process
- Each server restarts independently
Use Cases
This package is particularly useful for:
- Multi-Server Deployments: When you have Horizon running on multiple servers and need to restart all of them
- Code Deployments: After deploying new code, restart all workers across all servers
- Configuration Changes: When Horizon configuration changes and all workers need to reload
- Memory Management: Periodic restarts to clear memory leaks or reset worker state
Configuration
The package automatically configures a special supervisor for handling restart jobs. No manual configuration is required.
The restart supervisor is automatically configured with:
- Connection: Uses the same connection as your first Horizon environment
- Queue: Uses Horizon's internal queue name
- Processes: 1 worker to handle restart jobs
- Tries: 3 attempts per job
Comparison with Other Methods
| Method | Single Server | Multiple Servers | Graceful |
|---|---|---|---|
horizon:terminate |
✅ | ❌ | ✅ |
queue:restart |
✅ | ✅ | ✅ |
horizon:restart (this package) |
✅ | ✅ | ✅ |
Development
Testing
Run the test suite:
composer test
Code Style
Fix code style issues:
composer cs-fix
Static Analysis
Run static analysis:
composer analyse
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Security
If you discover any security related issues, please email huangdijia@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
Credits
Links
Related Packages
A small package to gain and export long time information from Laravel & Horizon...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v3.1.0 | >=8.1 | ^10.0| | MIT | |
| v3.0.0 | >=8.1 | ^10.0| | MIT | |
| v2.1.1 | >=8.0 | ^9.0| | MIT | |
| v2.1.0 | >=8.0 | ^9.0| | MIT | |
| v2.0.0 | >=8.0 | ^9.0 | MIT | |
| v1.1.3 | >=7.1.0 | ^5.7| | MIT | |
| 1.1.2 | >=7.1.0 | ^5.7| | MIT | |
| 1.1.1 | >=7.1.0 | ^5.7| | MIT | |
| 1.1.0 | >=7.1.0 | ^5.7| | MIT | |
| 1.0.8 | >=7.1.0 | ^5.7| | MIT | |
| 1.0.7 | >=7.1.0 | ^5.5| | MIT | |
| 1.0.6 | >=7.1.0 | ~5.5.0| | MIT | |
| 1.0.5 | >=7.1.0 | ~5.5.0| | MIT | |
| 1.0.4 | >=7.1.0 | ~5.5.0| | MIT | |
| 1.0.3 | >=7.1.0 | ~5.5.0| | MIT | |
| 1.0.2 | >=7.1.0 | 5.0.*| | MIT | |
| 1.0.1 | >=7.1.0 | 5.0.*| | MIT | |
| 1.0.0 | >=7.1.0 | 5.0.*| | MIT |
Pre-releases (2)
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v3.1.0-beta.1 | >=8.1 | ^10.0| | MIT | |
| v3.0.0-beta.1 | >=8.1 | ^10.0 | MIT |