Skip to content

Instantly share code, notes, and snippets.

@tOlorun
Forked from ichux/celery.sh
Created September 12, 2018 06:28
Show Gist options
  • Save tOlorun/2b5bf2a442a211b5d50a1a512fe49b1c to your computer and use it in GitHub Desktop.
Save tOlorun/2b5bf2a442a211b5d50a1a512fe49b1c to your computer and use it in GitHub Desktop.

Revisions

  1. @amatellanes amatellanes revised this gist Nov 1, 2014. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions celery.sh
    Original file line number Diff line number Diff line change
    @@ -56,8 +56,6 @@ i.active() // Get a list of active tasks
    i.scheduled // Get a list of tasks waiting to be scheduled
    i.reserved() # Get a list of tasks that has been received, but are still waiting to be executed

    celery -A tasks inspect stats # Show statistic about workers

    app.control.broadcast('shutdown') # shutdown all workers
    app.control.broadcast('shutdown', destination=['celer@worker'])

  2. @amatellanes amatellanes revised this gist Oct 21, 2014. 1 changed file with 15 additions and 3 deletions.
    18 changes: 15 additions & 3 deletions celery.sh
    Original file line number Diff line number Diff line change
    @@ -34,12 +34,20 @@ celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile
    celery -A proj inspect active # control and inspect workers at runtime
    celery -A proj inspect active [email protected]

    celery -A tasks control cancel_consumer # Force all worker to cancel consuming from a queue
    celery -A tasks control cancel_consumer foo -d worker1.local # Force an specified worker to cancel consuming from a queue
    celery -A proj inspect scheduled # list scheduled ETA tasks.

    celery -A proj control cancel_consumer # Force all worker to cancel consuming from a queue
    celery -A proj control cancel_consumer foo -d worker1.local # Force an specified worker to cancel consuming from a queue

    celery -A proj inspect active_queues # Get a list of queues that workers consume
    celery -A proj inspect active_queues -d celery@worker1 # Get a list of queues that a worker consumes

    celery -A proj inspect stats # show worker statistics.

    celery shell -I # Drop into IPython console.

    celery -A tasks result -t tasks.add dbc53a54-bd97-4d72-908c-937827009736 # See the result of a task.

    # Control workers
    i = app.control.inspect()
    i = app.control.inspect(['worker1.example.com', 'worker2.example.com'])
    @@ -54,4 +62,8 @@ app.control.broadcast('shutdown') # shutdown all workers
    app.control.broadcast('shutdown', destination=['celer@worker'])

    app.control.ping()
    app.control.ping(['celer@worker'])
    app.control.ping(['celer@worker'])

    # Inspecting queues in Redis
    redis-cli -h HOST -p PORT -n DATABASE_NUMBER llen QUEUE_NAME
    LRANGE queue_name 0 10 # Redis client
  3. @amatellanes amatellanes revised this gist Sep 28, 2014. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion celery.sh
    Original file line number Diff line number Diff line change
    @@ -48,4 +48,10 @@ i.active() // Get a list of active tasks
    i.scheduled // Get a list of tasks waiting to be scheduled
    i.reserved() # Get a list of tasks that has been received, but are still waiting to be executed

    celery -A tasks inspect stats # Show statistic about workers
    celery -A tasks inspect stats # Show statistic about workers

    app.control.broadcast('shutdown') # shutdown all workers
    app.control.broadcast('shutdown', destination=['celer@worker'])

    app.control.ping()
    app.control.ping(['celer@worker'])
  4. @amatellanes amatellanes revised this gist Sep 26, 2014. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion celery.sh
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,20 @@ celery multi stopwait w1 -A proj -l info # stop after executing tasks are compl
    celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile=/var/log/celery/%n%I.log # create pid and log files in the current directory

    celery -A proj inspect active # control and inspect workers at runtime
    celery -A proj inspect active [email protected]
    celery -A proj inspect active [email protected]

    celery -A tasks control cancel_consumer # Force all worker to cancel consuming from a queue
    celery -A tasks control cancel_consumer foo -d worker1.local # Force an specified worker to cancel consuming from a queue

    celery -A proj inspect active_queues # Get a list of queues that workers consume
    celery -A proj inspect active_queues -d celery@worker1 # Get a list of queues that a worker consumes

    # Control workers
    i = app.control.inspect()
    i = app.control.inspect(['worker1.example.com', 'worker2.example.com'])
    i.registered() // Show registred tasks for specified workers
    i.active() // Get a list of active tasks
    i.scheduled // Get a list of tasks waiting to be scheduled
    i.reserved() # Get a list of tasks that has been received, but are still waiting to be executed

    celery -A tasks inspect stats # Show statistic about workers
  5. @amatellanes amatellanes revised this gist Sep 11, 2014. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions celery.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,22 @@
    /* Useful celery config.

    app = Celery('tasks',
    broker='redis://localhost:6379',
    backend='redis://localhost:6379')

    app.conf.update(
    CELERY_TASK_RESULT_EXPIRES=3600,
    CELERY_QUEUES=(
    Queue('default', routing_key='tasks.#'),
    Queue('hipri', routing_key='tasks.#'),
    ),
    CELERY_ROUTES={
    'tasks.tasks.add': {'queue': 'hipri'},
    }
    )

    */

    celery -A tasks worker --loglevel=info # run the worker

    celery worker --help # list command-line options available
  6. @amatellanes amatellanes revised this gist Sep 8, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion celery.sh
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,7 @@ celery multi stop w1 -A proj -l info # stop workers aynchronously

    celery multi stopwait w1 -A proj -l info # stop after executing tasks are completed

    celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile=/var/log/celery/%n%I.log # create pid and log files in the current directory
    celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile=/var/log/celery/%n%I.log # create pid and log files in the current directory

    celery -A proj inspect active # control and inspect workers at runtime
    celery -A proj inspect active [email protected]
  7. @amatellanes amatellanes revised this gist Sep 6, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion celery.sh
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,8 @@ celery multi start w1 -A proj -l info # start one or more workers in the backgr

    celery multi restart w1 -A proj -l info # restart workers

    celery multi stop w1 -A proj -l info # stop workers
    celery multi stop w1 -A proj -l info # stop workers aynchronously

    celery multi stopwait w1 -A proj -l info # stop after executing tasks are completed

    celery multi start w1 -A proj -l info --pidfile=/var/run/celery/%n.pid --logfile=/var/log/celery/%n%I.log # create pid and log files in the current directory
  8. @amatellanes amatellanes created this gist Sep 6, 2014.
    9 changes: 9 additions & 0 deletions celery.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    celery -A tasks worker --loglevel=info # run the worker

    celery worker --help # list command-line options available

    celery multi start w1 -A proj -l info # start one or more workers in the background

    celery multi restart w1 -A proj -l info # restart workers

    celery multi stop w1 -A proj -l info # stop workers