Workers
Perforce Swarm uses background processes, called workers, to respond to events in the Perforce service. The default number of workers is 3, and each worker processes events for up to 10 minutes. When a worker terminates, a new one is spawned.
Note
Each worker maintains a connection to the Perforce service for the duration of its lifetime. This may impact your Perforce service management practices.
Worker status
To determine the current status of workers, visit the URL:
http://myswarm
/queue/status
The response is formatted in JSON, and looks like this:
{"tasks":0,"futureTasks":1,"workers":3,"maxWorkers":3,"workerLifetime":"595s"}
Manually start workers
To kick off a new worker process, visiting the URL:
http://myswarm
/queue/worker
Worker configuration
To adjust the configuration for workers, add a configuration block to the
data/config.php
file:
<?php
// this block should be a peer of 'p4'
'queue' => array(
'workers' => 3, // defaults to 3
'worker_lifetime' => 595, // defaults to 10 minutes (less 5 seconds)
'worker_task_timeout' => 1800, // defaults to 30 minutes
'worker_memory_limit' => '1G', // defaults to 1 gigabyte
),
workers
specifies the number of worker processes
that should be available. The default is 3. The
cron job ensures that new worker
processes are started when necessary. If the limit is reached or exceeded,
new worker processes are not started.
worker_lifetime
specifies the amount of time in
seconds that a worker process should run for. The default is 595 seconds
(10 minutes less 5 seconds). If a worker process exceeds this limit while
processing a task, it will complete the active task and then terminate.
worker_lifetime
does not cause tasks to terminate
mid-processing.
worker_task_timeout
specifies the maximum amount of
time in seconds that a worker process can spend processing a single task.
The default is 1800 seconds (30 minutes). This is useful for terminating
workers that might get stalled in a variety of situations.
worker_memory_limit
specifies the maximum amount of
memory that a worker process is allowed to use while processing a task.
The default is 1G
(1 gigabyte).