Giter Club home page Giter Club logo

celery-graceful-stop's Introduction

celery-graceful-stop

Celery plugin provides ability of graceful worker stopping.

Problem

Production deployment of long running tasks require worker to be stopped gracefully. Unfortunately celery got different behaviour:

  1. Receiving SIGTERM signal by celery results starting Warm shutdown procedure. Due this procedure, inspect and control commands become unavailable.
  2. More than that, all tasks are terminated forcely by the second SIGTERM with the Cold shutdown procedure.

This module provides more consistent approach to this problem, it

  1. overrides SIGTERM receiver to prevent default Warm shutdown and Cold shutdown worker behaviour,
  2. forces inspect and control commands to be working even after SIGTERM signal received.

Installation & Setup

pip install git+https://github.com/MnogoByte/celery-graceful-stop.git

Append your proj/celery.py file containg app instance with the following lines.

import celery_graceful_stop
celery_graceful_stop.register(app)

Settings

  • CELERY_GRACEFUL_STOP (boolean). Controls graceful stop function. (True by default)

Using with systemd

  1. Define 1 service per each worker you got (systemd require only one master pid for restart).
  2. Provide /etc/conf.d/celery_<service_name> configuration file for each worker.
  3. Add [email protected] file into your system.
  4. Register your service with systemctl enable celery@<service_name>.

Limitations

  • This module disables pool_shrink, pool_grow, autoscale, pool_reload, add_consumer, cancel_consumer control commands after receiving SIGTERM signal. Actually, you'll does not need to call them when the worker is shutting down, because worker will not starts new tasks.
  • This module has been tested only with celery 3.1 with pool=prefork.

Author

Antonov Mikhail

License

BSD - 3

celery-graceful-stop's People

Contributors

atin65536 avatar meteozond avatar

Watchers

 avatar  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.