- COPYRIGHT AND LICENSE
Resque::Worker - Does the hard work of babysitting Resque::Job's
The Resque object running this worker.
Queues this worker should fetch jobs from.
Unique identifier for the running worker. Used to set process status all around.
The worker stringify to this attribute.
Set to a true value to make this worker report what's doing while on work().
Set it to a true value to stop this worker from fork jobs.
By default, the worker will fork the job out and control the children process. This make the worker more resilient to memory leaks.
PID of current running child.
When true, this worker will shutdown after finishing current job.
When true, this worker won't proccess more jobs till false.
Float representing the polling frequency. The default is 5 seconds, but for a semi-active app you may want to use a smaller value.
Stop processing jobs after the current one has completed (if we're currently running one).
Start processing jobs again after a pause
Schedule this worker for shutdown. Will finish processing the current job.
Kill the child and shutdown immediately.
Calling this method will make this worker to start pulling & running jobs from queues().
This is the main wheel and will run while shutdown() is false.
Perform() one job and wait till it finish.
Call perform() on the given Resque::Job capturing and reporting any exception.
Kills the forked child immediately, without remorse. The job it is processing will not be completed.
Add a queue this worker should listen to.
Stop listening to the given queue.
Pull the next job to be precessed.
Set worker and working status on the given Resque::Job.
Inform the backend this worker has done its current job
What time did this worker start? Returns an instance of DateTime.
TODO: not working in this release. This is returning a string used internally.
Tell Redis we've started
Returns a hash explaining the Job we're currently processing, if any.
Returns a string representing the current worker state, which can be either working or idle
Boolean - true if working, false if not
Boolean - true if idle, false if not
Given a string, sets the procline ($0) and logs. Procline is always in the format of: resque-VERSION: STRING
Helper method called by work() to:
1. register_signal_handlers() 2. prune_dead_workers(); 3. register_worker();
Registers the various signal handlers a worker responds to.
TERM: Shutdown immediately, stop processing jobs. INT: Shutdown immediately, stop processing jobs. QUIT: Shutdown after the current job has finished processing. USR1: Kill the forked child immediately, continue processing jobs. USR2: Don't process any new jobs CONT: Start processing jobs again after a USR2
Looks for any workers which should be running on this server and, if they're not, removes them from Redis.
This is a form of garbage collection. If a server is killed by a hard shutdown, power failure, or something else beyond our control, the Resque workers will not die gracefully and therefore will leave stale state information in Redis.
By checking the current Redis state against the actual environment, we can determine if Redis is old and clean it up a bit.
Registers ourself as a worker. Useful when entering the worker lifecycle on startup.
Unregisters ourself as a worker. Useful when shutting down.
Returns an Array of string pids of all the other workers on this machine. Useful when pruning dead workers on startup.
If verbose() is true, this will print to STDERR.
Retrieve from Resque::Stat many jobs has done this worker. Pass a true argument to increment by one.
How many failed jobs has this worker seen. Pass a true argument to increment by one.
Returns a single worker object. Accepts a string id.
Returns all worker registered on the backend.
Returns true if the given worker id exists on redis() backend.
Diego Kuperman <email@example.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Diego Kuperman.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.