Console utilities

Celery beat

The scheduling process for periodic tasks.

This allows to schedule and execute scheduled tasks.

  • Command:

    aos-scheduler-beat
    
  • systemd service name:

    aos-scheduler-beat.service
    
Utility arguments
Name Description Default value
--debug The argument allows to start the service in the DEBUG mode. False
--logfile File path for logging. /var/log/aos/scheduler/beat.log

Celery beat fault tolerance

If several beat processes are launched (including on different servers) configured for the same database and server RabbitMQ, the following algorithm will work synchronizing tasks:

  1. One of the beat processes determines that the task is ready according to the schedule to be sent to the queue for processing by worker processes;
  2. The beat process creates a queue in the message broker with the exclusive attribute (this attribute turns on the prohibition of connecting more than one client to the queue and automatically deletes the queue after the connection is closed). The queue name corresponds to this instance of the task is celery_beat_{task_id}_{run_count_id}.mutex. Where:
    • task_id is task ID;
    • run_count_id is the number of task launches completed. If the task was not executed, the parameter value is 0.
  3. If at the moment another beat-process is trying to process the same task, then by mistake connecting to the exclusive-queue it is determined that the task is already being processed and this task is not sent again to the queue;
  4. The first beat-process sends a task instance to the processing queue, makes forced synchronization with the database in order to update the task’s value total_run_count, the number of task starts and closes the connection to the exclusive-queue;
  5. If after that any other beat-process tries to process the same task, then it checks the run_count_id with the currently saved total_run_count in the database and does not re-process the task if it was already executed with the current one for the given beat process run_count_id.

Celery worker

Processing periodic tasks.

This monitors the appearance of tasks in the queue of scheduled tasks and executes them.

  • Command:

    aos-scheduler-worker
    
  • systemd service name:

    aos-scheduler-worker.service
    
Utility arguments
Name Description Default value
--debug The argument allows to start the service in the DEBUG mode. False
--logfile File path for logging. /var/log/aos/scheduler/worker.log