Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding a parameter to initialize the master with a specified number o…

…f workers
  • Loading branch information...
commit 48016f5332a75558ba5a684ce781c3cdbbd23a86 1 parent 0d5cb4a
@andrewtimberlake authored
Showing with 6 additions and 6 deletions.
  1. +2 −2 lib/cascade/master.rb
  2. +4 −4 spec/lib/cascade/master_spec.rb
View
4 lib/cascade/master.rb
@@ -12,7 +12,7 @@ def initialize(worker_class=Worker)
SIG_QUEUE = []
SELF_PIPE = []
- def start
+ def start(workers=2)
init_self_pipe!
[:TERM, :INT, :QUIT, :TTIN, :TTOU, :CHLD].each do |sig|
@@ -22,7 +22,7 @@ def start
end
end
- (0..1).each do |i|
+ (0..workers-1).each do |i|
CHILDREN << fork_worker(i)
end
View
8 spec/lib/cascade/master_spec.rb
@@ -31,7 +31,7 @@ def capture_output
it "master and all workers should exit on TERM" do
output = capture_output do
master = fork do
- Master.new(TestWorker).start
+ Master.new(TestWorker).start(2)
end
sleep 0.2
Process.kill(:TERM, master)
@@ -48,7 +48,7 @@ def capture_output
it "auto restarts a worker which dies" do
output = capture_output do
master = fork do
- Master.new(DyingWorker).start
+ Master.new(DyingWorker).start(2)
end
sleep 0.2
Process.kill(:TERM, master)
@@ -63,7 +63,7 @@ def capture_output
it "adds a worker on SIGTTIN" do
output = capture_output do
master = fork do
- Master.new(TestWorker).start
+ Master.new(TestWorker).start(2)
end
sleep 0.2
Process.kill(:TTIN, master)
@@ -80,7 +80,7 @@ def capture_output
it "removes a worker on SIGTTOU" do
output = capture_output do
master = fork do
- Master.new(TestWorker).start
+ Master.new(TestWorker).start(2)
end
sleep 0.2
Process.kill(:TTOU, master)
Please sign in to comment.
Something went wrong with that request. Please try again.