Module: Resque
- Defined in:
- lib/resque/forker.rb
Defined Under Namespace
Classes: Forker
Instance Method Summary collapse
-
#fork!(options = nil) ⇒ Object
Forks workers to take care of the workload.
-
#setup(&block) ⇒ Object
Specify what needs to be done to setup the application.
-
#teardown(&block) ⇒ Object
Do this before exiting or before reloading.
Instance Method Details
#fork!(options = nil) ⇒ Object
Forks workers to take care of the workload.
The workload is an array of queue names, one entry for each worker. For example, if you want to run four workers processing all queues.
Resque.fork! ["*"] * 4
If you want four workers, all of which will be processing imports, but only two processing exports:
Resque.fork! ["import", "import,export"] * 2
Options are:
-
:logger – Which Logger to use (default logger to stdout)
-
:interval – Processing interval (default to 5 seconds)
-
:terminate – Timeout running teardown block (default to 5 seconds)
-
:verbose – Be verbose.
-
:very_verbose – Make :verbose look quiet.
-
:workload – The initial workload.
You can also set these options from the Resque.setup hook.
242 243 244 |
# File 'lib/resque/forker.rb', line 242 def fork!( = nil) Resque::Forker.new().run end |
#setup(&block) ⇒ Object
Specify what needs to be done to setup the application. This is the place to load Rails or do anything expensive. For example:
Resque.setup do
require File.dirname(__FILE__) + "/../config/environment"
ActiveRecord.disconnect
end
215 216 217 |
# File 'lib/resque/forker.rb', line 215 def setup(&block) block ? (@setup = block) : @setup end |
#teardown(&block) ⇒ Object
Do this before exiting or before reloading.
220 221 222 |
# File 'lib/resque/forker.rb', line 220 def teardown(&block) block ? (@teardown = block) : @teardown end |