Giter Club home page Giter Club logo

elegant-laravel-worker's Introduction

Elegant Laravel Worker for Laravel 5.3

Elegant way to gracefully handle SIGTERM signal in Laravel 5.3 queue worker. In Laravel >=5.4 this issue is beautifully handled.

Install

Via Composer

$ composer require iivannov/elegant-laravel-worker

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

'providers' => [
    ...
    Iivannov\ElegantWorker\ElegantWorkerServiceProvider::class,
];

Use Case

Gracefully stop a Queue Worker by using SIGTERM signal.

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

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.

Elegant Behaviour:

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

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

elegant-laravel-worker's People

Contributors

iivannov avatar

Stargazers

Qin avatar Sh1d0w avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.