New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

jdavidbakr/multi-server-event

This package extends Laravel's native Command Event class to allow for managing events fired on the same system with multiple servers, preventing an event from firing more than once
187,817 37

Larablocks Analysis

jdavidbakr/multi-server-event works with Laravel 5 (latest release 2.0.5, Feb 10, 2018), which reached end of life: no more fixes, even for security.

Recommendation checks

Not advised

Not advised: marked abandoned on Packagist.

  • Marked abandoned on Packagist
  • Supports only Laravel 5, past end of life
  • No release in the last 12 months (last: Feb 10, 2018)
  • 2,940 downloads a month (needs 10,000)
  • 37 GitHub stars (needs 100)

State

Abandoned
  • Packagist marks this package abandoned.
  • Last stable release: Feb 10, 2018.
  • No releases in the last 12 months.
  • First released: Aug 11, 2015.
  • Monthly downloads: 2,940.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.

Install
composer require jdavidbakr/multi-server-event
Latest Version:2.0.5
PHP:>=5.5.9
Laravel:5
License:MIT
Last Updated:Feb 10, 2018
Links: GitHub  ·  Packagist
Maintainer: jdavidbakr

Multi Server Event

Latest Version on Packagist Software License Total Downloads

This package extends Laravel's native Event class to include the ability to block events from occurring aross multiple servers, as would be the case if you have a laravel instance behind a load balancer in an auto-scaling situation.

It uses a database table to track the currently running process, and each server generates a unique key to lock the command. In order to prevent a condition where a short-running command's lock doesn't last long enough, we are implementing a minimum 10 second break between the completion of the command and its next execution time, so if a command runs every minute but takes between 50 and 59 seconds to complete, the next command will be delayed one more minute.

For Laravel < 5.4, please use version 1.X
Upgrading from version 1.X

If upgrading from version 1.X, please note the change in the defineConsoleSchedule() command in app\Console\Kernel.php.

Installation

$ composer require jdavidbakr/multi-server-event

The new event structure uses a database table to track which server is currently executing an event. You must create the database table using the provided migration. To do this, add the following to the $commands array in \App\Console\Kernel.php:

\jdavidbakr\MultiServerEvent\Commands\MultiServerMigrationService::class,

then perform the migration

php artisan make:migration:multi-server-event
php artisan migrate

Now we want to change the default schedule IoC to use this alternate one. In app\Console\Kernel.php add the following function:

/**
 * Define the application's command schedule.
 *
 * @return void
 */
protected function defineConsoleSchedule()
{
    $this->app->instance(
        Schedule::class,
        $schedule = new \jdavidbakr\MultiServerEvent\Scheduling\Schedule()
    );

    $this->schedule($schedule);
}

Usage

When composing your schedule, simply add "withoutOverlappingMultiServer()" to the command, i.e.

$schedule->command('inspire')
    ->daily()
    ->withoutOverlappingMultiServer();

This will prevent multiple servers from executing the same event at the same time.

When composing your schedule, you can also ensure that cron is not stuck, simply add "ensureFinishedMultiServer()" to the command, i.e.

$schedule->command('inspire')
    ->daily()
    ->withoutOverlappingMultiServer()
    ->ensureFinishedMultiServer(30);

This will prevent from stuck commands during lost connection or deployment. Note, choose time to be enough to mark as "stuck", fox example, long running command should have bigger tolerance time. You can track such events how ofter it happens by binding listeners on EnsureCleanUpExecuted event

Testing

phpunit

Related Packages

madlab/multi-server-scheduling

This package extends Laravel's native Command Event class to add functionality t...

18,564 7
custom-d/run-scheduler

A run scheduler

1,427
fideloper/proxy

Set trusted proxies for Laravel

180,308,034 7,301
oneduo/laravel-mail-scheduler

A simple way to send batch emails

2,060 7
worksofallen/laravel-mail-scheduler

A simple way to send batch emails

1,753 0

Version History

Version Released PHP Laravel License
2.0.5 >=5.5.9 >=5.4.26 <5.6 MIT
2.0.4 >=5.5.9 >=5.4.26 MIT
2.0.3 >=5.5.9 >=5.4.26 MIT
2.0.2 >=5.5.9 >=5.4.17 MIT
2.0.1 >=5.5.9 5.4.* MIT