justbetter/laravel-horizon-restarter

Automatically restart Laravel Horizon

1.0.0 2025-05-06 06:35 UTC

This package is auto-updated.

Last update: 2025-05-06 06:38:45 UTC


README

Banner

Laravel Horizon Restarter

Tests Coverage Analysis Total downloads

Automatically restart Horizon after a given amount of jobs.

Why?

PHP is not designed for long running processes, it can sometimes run into issues when it has been running for too long. Horizon workers can automatically be stopped after processing a configured amount of jobs (maxjobs). However, depending on the balanceMaxShift and balanceCooldown, it may take a while before all processes are running again. This package will automatically restart Horizon gracefully after a given amount of jobs have been processed.

This package is to simplify configuration and to ensure that Horizon is restarted automatically.

Installation

You can install the package via composer:

composer require justbetter/laravel-horizon-restarter

Configuration

By default, after 100.000 jobs have been processed, Horizon will be terminated. This can be configured by adding the following to your .env file:

HORIZON_RESTARTER_THRESHOLD=100000

Quality

To ensure the quality of this package, run the following command:

composer quality

This will execute three tasks:

  1. Makes sure all tests are passed
  2. Checks for any issues using static code analysis
  3. Checks if the code is correctly formatted

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

JustBetter logo