8000 Add support for specifying max slave count via SPORK_SLAVES_COUNT by jarmo · Pull Request #241 · sporkrb/spork · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for specifying max slave count via SPORK_SLAVES_COUNT #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/spork/run_strategy/magazine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class Spork::RunStrategy::Magazine < Spork::RunStrategy

Slave_Id_Range = 1..2 # Ringserver uses id: 0. Slave use: 1..MAX_SLAVES
Slave_Id_Range = 1..(ENV["SPORK_SLAVES_COUNT"] && ENV["SPORK_SLAVES_COUNT"].to_i || 2) # Ringserver uses id: 0. Slave use: 1..MAX_SLAVES

def slave_max
Slave_Id_Range.to_a.size
Expand Down
18 changes: 18 additions & 0 deletions spec/spork/run_strategy/magazine_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe Spork::RunStrategy::Magazine do

before { ENV["SPORK_SLAVES_COUNT"] = nil }
after { ENV["SPORK_SLAVES_COUNT"] = nil }

it "uses 2 slaves by default" do
Spork::RunStrategy::Magazine::Slave_Id_Range.should == (1..2)
end

it "allows to override max slaves count via environment variable" do
ENV["SPORK_SLAVES_COUNT"] = "42"
Spork::RunStrategy.send :remove_const, :Magazine
load "spork/run_strategy/magazine.rb"
Spork::RunStrategy::Magazine::Slave_Id_Range.should == (1..42)
end
end
0