2017 © Pedro Peláez
 

library elegant-laravel-worker

Elegant way to gracefully handle SIGTERM signal in Laravel queue worker

image

iivannov/elegant-laravel-worker

Elegant way to gracefully handle SIGTERM signal in Laravel queue worker

  • Thursday, February 23, 2017
  • by iivannov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 948 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

Elegant Laravel Worker for Laravel 5.3

Elegant way to gracefully handle SIGTERM signal in Laravel 5.3 queue worker., (*1)

In Laravel >=5.4 this issue is beautifully handled.

Install

Via Composer, (*2)

``` bash $ composer require iivannov/elegant-laravel-worker, (*3)



## Register in Laravel To replace the default Queue Worker with this one, you need to add the ElegantWorkerServiceProvider class to the providers array in your `config\app.php` ``` php 'providers' => [ ... Iivannov\ElegantWorker\ElegantWorkerServiceProvider::class, ];

Use Case

Gracefully stop a Queue Worker by using SIGTERM signal., (*4)

Why would I stop the Worker?

There are many cases that will require to restart the worker. - start/stop workers when auto-scaling - temporarily stop the execution of tasks - reloading supervisor (or another monitoring tool) configuration, (*5)

Default Laravel Behaviour:

When SIGTERM is received by the Worker it interrupts immediately the currently processed job, which may break your application by not letting the job finish leading to unexpected results., (*6)

Elegant Behaviour:

When SIGTERM is received by the Worker it will wait for the currently processed job to finish and then will exit gracefully., (*7)

What do we solve?

  • Interrupting long running jobs executing consecutive interrelated tasks
  • Interrupting in the middle of a DB transaction causing a deadlock
  • Prevent repeating the execution of a an interrupted job when it is picked up again by a Worker

The Versions

23/02 2017

dev-master

9999999-dev

Elegant way to gracefully handle SIGTERM signal in Laravel queue worker

  Sources   Download

MIT

The Requires

 

by Ivan Ivanov
by Lachezar Todorov

laravel php queue worker deadlock sigterm

23/02 2017

1.0.0

1.0.0.0

Elegant way to gracefully handle SIGTERM signal in Laravel queue worker

  Sources   Download

MIT

The Requires

 

by Ivan Ivanov
by Lachezar Todorov

laravel php queue worker deadlock sigterm