The Task Queue System

Overview

Events in cPanel & WHM often cause one or more services to restart. =
For example, if you add a subdomain, the system restarts Apache and the nam=
eserver daemon. On busy servers, these restart requests can degrade th=
e quality of service.

To handle these requests, cPanel & WHM includes a system to queue an=
d process tasks from various subsystems. Those subsystems do n=
ot perform restarts and other requests directly. Instead, the=
task queue system combines multiple instances of an outstanding request in=
to a single action in order to improve server response time.

The queueprocd daemon, which resides in the&nbsp=
;/usr/local/cpanel/libexec directory, processes the =
task queue periodically. The startup process starts this daemon. To ma=
nage the daemon, use the /usr/local/cpanel/scripts/restartsrv_qu=
eueprocd script.

The chksrvd daemon monitors the queue=
procd daemon.

The task queue system stores the queue of tasks as JSON files in the&nb=
sp; /var/cpanel/taskqueue directory.

The servers_queue scri=
pt

You can use the following arguments when you call the /u=
sr/local/cpanel/bin/servers_queue script:

Argument

Description

Example

queue

Use this argument to pass a quoted command string to add to the task que=
ue.

If the system successfully adds that command to the task queue, you =
will receive a message that resembles the following example:

=20

Id: TQ:TaskQu=
eue:3

=20

In this example, TQ:TaskQueue:3 represents the task's=
ID number in the task queue.

If you pass an invalid command to the task queue, you will receive t=
he following error message, where command represents the comma=
nd that you specified:

=20

No know=
n processor for 'command'. at /usr/local/lib/perl5/site_perl/5.8.8/

=
=20

=20

/usr/local/cp=
anel/bin/servers_queue queue 'apache_restart'

=20

unqueue

Use this argument to remove a task from the task queue. When you use thi=
s argument, you must pass the task's unique task ID with i=
t. The system outputs this number when you queue a task, or you can find th=
e task ID number in the/var/cpanel/taskqueue/servers_queue.json file.

If the system successfully removes the task, you will receive a success =
message that resembles the following example:

=20

1 tasks unque=
ued

=20

=20

/usr/local/cp=
anel/bin/servers_queue unqueue TQ:TaskQueue:3

=20

schedule

Use this argument to pass a wait time, in seconds, and a quoted command =
string to add to the task queue. The task queue will not p=
rocess the command until after the wait time passes.

If the system successfully adds the command to the task queue, you w=
ill receive a message that resembles the following example:

=20

Id: TQ:TaskQu=
eue-Scheduler:43

=20

In this example, TQ:TaskQueue-Scheduler:4=
3 represents the task's ID number in the task queue.

If you pass an invalid command to the task queue, you will receive t=
he following error message, where command represents the comma=
nd that you specified:

=20

No know=
n processor for 'command'. at /usr/local/lib/perl5/site_perl/5.8.8/

=
=20

=20

/usr/local/cp=
anel/bin/servers_queue schedule 600 'apache_restart'

=20

unschedule

Use this argument to remove a task from the task queue. When you use thi=
s argument, you must pass the task's unique task ID with i=
t. The system outputs this number when you queue a task, or you can find th=
e task ID number in the/var/cpanel/taskqueue/servers_queue.json file.

If the system successfully removes the task, you will receive a success =
message that resembles the following example: