定制 ralphjsmit/laravel-horizon-cron-supervisor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ralphjsmit/laravel-horizon-cron-supervisor

Composer 安装命令:

composer require ralphjsmit/laravel-horizon-cron-supervisor

包简介

A modern solution for running Laravel Horizon with a CRON-based supervisor.

README 文档

README

laravel-horizon-cron-supervisor@2x

A modern solution for running Laravel Horizon with a cron-based supervisor

Run Laravel Horizon on cheap hosting environments without Supervisor🤑

This Laravel package automatically checks every three minutes if your Laravel Horizon instance is still running. In that way, it is the perfect replacement for the normally recommended Supervisor 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.

Installation

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.

Publishing the config file

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.

<?php

return [
    /**
     * 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),
];

How does this work with new deployments?

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 in maintenance 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 deployment 

php artisan down
php artisan horizon:terminate

# Do deployment logic
# Horizon will not be restarted until you put the application out of maintenance mode

php artisan horizon
php 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.

About the package

This package was created by Ralph J. Smit. Checkout my website ralphjsmit.com for Laravel and development-related tutorials.

The package was inspired by this StackOverflow question and my need for this as well. Special thanks to ahoffman for his code on running and checking whether Horizon is active.

ralphjsmit/laravel-horizon-cron-supervisor 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 10.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 63
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 63
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-25