Class: StalkBoss::Stalk
- Inherits:
-
Object
- Object
- StalkBoss::Stalk
- Defined in:
- lib/stalk_boss.rb
Instance Attribute Summary collapse
-
#error_log ⇒ Object
Returns the value of attribute error_log.
-
#log ⇒ Object
Returns the value of attribute log.
-
#worker ⇒ Object
Returns the value of attribute worker.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(worker, workers = 1, log = nil, error_log = nil) ⇒ Stalk
constructor
A new instance of Stalk.
- #pids ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(worker, workers = 1, log = nil, error_log = nil) ⇒ Stalk
Returns a new instance of Stalk.
39 40 41 42 43 44 45 |
# File 'lib/stalk_boss.rb', line 39 def initialize(worker, workers=1, log=nil, error_log=nil) super @worker = worker @workers = workers @log = log @error_log = error_log end |
Instance Attribute Details
#error_log ⇒ Object
Returns the value of attribute error_log.
37 38 39 |
# File 'lib/stalk_boss.rb', line 37 def error_log @error_log end |
#log ⇒ Object
Returns the value of attribute log.
37 38 39 |
# File 'lib/stalk_boss.rb', line 37 def log @log end |
#worker ⇒ Object
Returns the value of attribute worker.
37 38 39 |
# File 'lib/stalk_boss.rb', line 37 def worker @worker end |
#workers ⇒ Object
Returns the value of attribute workers.
37 38 39 |
# File 'lib/stalk_boss.rb', line 37 def workers @workers end |
Instance Method Details
#pids ⇒ Object
47 48 49 |
# File 'lib/stalk_boss.rb', line 47 def pids @pids ||= [] end |
#start ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/stalk_boss.rb', line 51 def start (1..@workers).each do pids << fork do STDOUT.reopen(File.open(@log, 'a')) if @log STDERR.reopen(File.open(@error_log, 'a')) if @error_log STDERR.sync = STDOUT.sync = true exec 'bossed_stalk', @worker end end end |