Console commands
WORKERS RELATED
JOBS RELATED
QUEUES RELATED
-
cake CakeResque.CakeResque start
To start one or multiple worker
Options
Option Value Description -u
or--user
[username] User running your php application, usually www-data for apache on a linux box.
Using a different user than the php one can lead to permissions problems.-q
or--queue
[queue[,queue]] A list of queues name, separated with a comma -i
or--interval
[second] Number of seconds between each polling. -n
or--workers
[count] Number of workers to create. All these workers will have the same options.
Uses pcntl to fork the process, ensure that you PHP is compiled with it.-l
or--log
[path] Absolute or relative path to the Process Stream log file.
Relative path is relative to CakePHP app/tmp/logs.--log-handler
[handlername] Worker Stream log handler --log-handler-target
[args] Argument passed to the log handler To create multiple workers with different options, just runWorkers will be started with default settings defined in bootstrap when the option is missing.start
again with different optionsExamples
Let's start a new worker with default settings
cake CakeResque.CakeResque startCreating workers Starting worker ... Done
Let's start 3 workers, polling the queue
user-activity
cake CakeResque.CakeResque start -n 3 -q user-activityCreating workers Starting worker ... Done x3
Notice thex3
, meaning that 3 workers are created.
Let's start a new worker, for running tests. Testing user is
jenkins
, and all output should go to/var/log/resque-test.log
cake CakeResque.CakeResque start -u jenkins -l /var/log/resque-test.logCreating workers Starting worker ... Done
-
cake CakeResque.CakeResque stop
To stop workers
If more than one worker is running, it will display a list of worker to choose from.
Flags
Flag Description -f
or--force
Force workers shutdown, without waiting for jobs to finish processing. -a
or--all
Stop all workers at once Examples
Let's try stopping workers. There is only one active worker.
cake CakeResque.CakeResque stopStopping workers Killing 15492 ... Done
15492 is the PID of the worker process
If we have more than one active workers, it will display the list of workers
cake CakeResque.CakeResque stopStopping workers Active workers list : [ 1] - KAMISAMA-MAC.local:15881:achievement, started 2 seconds ago [ 2] - KAMISAMA-MAC.local:15867:default, started 3 seconds ago [ 3] - KAMISAMA-MAC.local:15882:achievement, started 2 seconds ago [ 4] - KAMISAMA-MAC.local:15868:default, started 3 seconds ago [all] - Stop all workers Worker to kill : (1/2/3/4/all) >
It will ask you back for the number of the worker to kill, or type
all
to kill all workers. Let's stop the worker #2.> 2Killing 15867 ... Done
To stop all workers at once
cake CakeResque.CakeResque stop --allStopping workers Killing 15881 ... Done Killing 15882 ... Done Killing 15868 ... Done
-
cake CakeResque.CakeResque restart
To restart all workers
Examples
Let's try stopping workers. There is only one active worker.
cake CakeResque.CakeResque restartStopping workers Killing 16080 ... Done Killing 16094 ... Done Killing 16081 ... Done Killing 16095 ... Done Restarting workers Starting worker ... Done x2 Starting worker ... Done x2
Notice thex2
, meaning that each start create 2 new workers, for a total of 4 new workers. -
cake CakeResque.CakeResque pause
To pause workers
If more than one worker is running, it will display a list of worker to choose from.
Flags
Flag Description -a
or--all
Pause all workers at once Examples
If we have more than one active workers, it will display the list of workers
cake CakeResque.CakeResque stopPausing workers Active workers list : [ 1] - KAMISAMA-MAC.local:15881:achievement, started 2 seconds ago [ 2] - KAMISAMA-MAC.local:15867:default, started 3 seconds ago [ 3] - KAMISAMA-MAC.local:15882:achievement, started 2 seconds ago [ 4] - KAMISAMA-MAC.local:15868:default, started 3 seconds ago [all] - Pause all workers Worker to pause : (1/2/3/4/all) >
It will ask you back for the number of the worker to pause, or type
all
to pause all workers. Let's pause the worker #2.> 2Pausing 15867 ... Done
Requires the php PCNTL extension -
cake CakeResque.CakeResque resume
To resume paused workers
If more than one worker is paused, it will display a list of worker to choose from.
Flags
Flag Description -a
or--all
Resume all workers at once Requires the php PCNTL extension -
cake CakeResque.CakeResque cleanup
To cleanup workers
Cleaning up a worker will immediately force terminating the job it is working on.
If more than one worker is running, it will display a list of worker to choose from.Flags
Flag Description -a
or--all
Cleanup all workers at once Requires the php PCNTL extension -
cake CakeResque.CakeResque load
To load all preconfigured workers
To start a batch of pre-configured queues (in your bootstrap). Documentation inside the bootstrap.php
Examples
If you have 2 pre-configured workers
cake CakeResque.CakeResque loadLoading predefined workers Starting worker ... Done Starting worker ... Done
-
cake CakeResque.CakeResque stats
To display some stats about the workers
Examples
With 2 active workers
cake CakeResque.CakeResque statsResque Statistics --------------------------------------------------------------- Jobs Stats Processed Jobs : 3972 Failed Jobs : 2 Queues Stats Queues count : 1 - default : 0 pending jobs Workers Stats Workers count : 2 REGULAR WORKERS * KAMISAMA-MAC.local:16391:default - Started on : Wed Sep 26 16:22:16 EDT 2012 - Processed Jobs : 0 - Failed Jobs : 0 * KAMISAMA-MAC.local:16406:default - Started on : Wed Sep 26 16:22:23 EDT 2012 - Processed Jobs : 0 - Failed Jobs : 0
-
cake CakeResque.CakeResque tail
To monitor the logs files
Display the content of the log file onscreen.
Will display a list of logs file to choose from, if more than one log file is present.Examples
If you have only one log file, located at
/var/log/resque-worker.log
, it will directly tail itcake CakeResque.CakeResque tailTailing log file Tailing /var/log/resque-worker.log [content of you log file] ... ...
If more than one log file is used, a list will be displayed
cake CakeResque.CakeResque tailTailing log file [ 1] - /var/log/resque-worker-1.log [ 2] - /var/log/resque-worker-2.log Choose a log file to tail : (1/2) > 1Tailing /var/log/resque-worker-1.log [content of you log file] ... ...
-
cake CakeResque.CakeResque startscheduler
To start the Scheduler Worker
The Scheduler must be enabled in your bootstrap, under
CakeResque.Scheduler.enabled
.
Only one scheduler worker can run at one time.
Theload
command will automatically start the Scheduler Worker if scheduled jobs is enabledOptions
Option Value Description -i
or--interval
[second] Number of seconds between each polling. Examples
cake CakeResque.CakeResque startschedulerCreating the scheduler worker Starting the scheduler worker ... Done
If you attempt to start an already started scheduler worker
cake CakeResque.CakeResque startschedulerCreating the scheduler worker The scheduler worker is already running
-
cake CakeResque.CakeResque enqueue [queue] [jobclass] "[args[,args]]" [track]
To enqueue a new job
Takes 3 arguments :
Argument Description queue
Name of the queue to add the job to jobclass
Job classname.
Plugin syntax (PluginName.ClassName
) is also available.args
List of arguments to pass to the job
First index is the name of the function to call, within the Shell, other indices are passed to the said function in `$this->args` variable.
If passing multiple arguments, separate them with a comma.Don't' forget to quote your arguments if they contains spacestrack
Optional, 0
or1
Whether to track the job status
Examples
Enqueueing a new job
cake CakeResque.CakeResque enqueue default Friend "findNewFriends,John Doe,Ghana"Adding a job to worker Successfully enqueued Job #687e11c818b10875be01aaf93fe7e2f0
-
cake CakeResque.CakeResque enqueueIn [wait] [queue] [jobclass] "[args[,args]]" [track]
To enqueue a new job after a number of seconds
Takes 4 arguments :
Argument Description wait
Number of seconds to wait before queueing the job enqueue
.Examples
Scheduling a new job in 5 seconds
cake CakeResque.CakeResque enqueueIn 5 default Friend "findNewFriends,John Doe,Ghana"Adding a job to worker Successfully scheduled Job #687e11c818b10875be01aaf93fe7e2f0
-
cake CakeResque.CakeResque enqueueAt [time] [queue] [jobclass] "[args[,args]]" [track]
To enqueue a new job at a certain time
Takes 4 arguments :
Argument Description wait
Unix timestamp enqueue
.Examples
Scheduling a new job
cake CakeResque.CakeResque enqueueAt 1359612628 default Friend "findNewFriends,John Doe,Ghana"Adding a job to worker Successfully scheduled Job #687e11c818b10875be01aaf93fe7e2f0
-
cake CakeResque.CakeResque track [JOB-ID]
To track the status of a job
To track a job status, you must enable it first. Set
CakeResque.Job.track
totrue
to enable job status tracking for all jobs.
You can also enable it on a per-job basis: set the fourth argument ofCakeResque::enqueue()
totrue
.Job status are kept only for 24 hours. This command will return
Unknown
if the job ID is not valid, or when the job status is expired or disabled.When the job failed, this command will also display the job and error details.
Examples
cake CakeResque.CakeResque track 687e11c818b10875be01aaf93fe7e2f0Tracking job status Status : complete
-
cake CakeResque.CakeResque clear [QUEUE-NAME]
To clear all queue's jobs
if [QUEUE-NAME] is not supplied, it will display the list of queues. If only one queue exists, it will automatically clear that queue.
Flags
Flag Description -a
or--all
Clear all queues at once Requires the php PCNTL extension