huangdijia/laravel-horizon-restart 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

huangdijia/laravel-horizon-restart

Composer 安装命令:

composer require huangdijia/laravel-horizon-restart

包简介

Horizon Restart for Laravel.

README 文档

README

Latest Test Latest Stable Version Total Downloads Monthly Downloads Daily Downloads License PHP Version Require

中文文档

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:

  1. Discover all running Horizon supervisors
  2. Dispatch a restart job to each supervisor's queue
  3. Gracefully terminate each supervisor (similar to horizon:terminate)
  4. Horizon will automatically restart the supervisors

How It Works

When you run horizon:restart, the package:

  1. Discovers Supervisors: Queries the Horizon master supervisor repository to find all active supervisors
  2. Dispatches Jobs: Creates a HorizonRestartJob for each supervisor and dispatches it to that supervisor's queue
  3. Executes Termination: Each job runs on its respective server and calls horizon:terminate locally
  4. 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

huangdijia/laravel-horizon-restart 适用场景与选型建议

huangdijia/laravel-horizon-restart 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105.95k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2018 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「horizon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 huangdijia/laravel-horizon-restart 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 huangdijia/laravel-horizon-restart 我们能提供哪些服务?
定制开发 / 二次开发

基于 huangdijia/laravel-horizon-restart 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 105.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-19