Navigation Menu

Skip to content

Commit

Permalink
Runner now remembers -r, -D and -V parameters
Browse files Browse the repository at this point in the history
so that clustered servers inherit those and
`restart` keep your parameters.
  • Loading branch information
macournoyer committed Jul 18, 2008
1 parent f67fb18 commit a8ed858
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,4 +1,6 @@
== 1.0.0 The Big release
* Runner now remembers -r, -D and -V parameters so that clustered servers inherit those and
`restart` keep your parameters.
* Make Set-Cookie header, in Rails adapter, compatible with current Rack spec [Pedro Belo]
[#73, state:resolved]
* Add --no-epoll option to disable epoll usage on Linux [#61 state:resolved]
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -57,7 +57,7 @@ You need to setup a config.ru file and pass it to the thin script:

run app

thin start -r config.ru
thin start -R config.ru

See example directory for more samples and run 'thin -h' for usage.

Expand Down
13 changes: 9 additions & 4 deletions lib/thin/runner.rb
Expand Up @@ -40,7 +40,8 @@ def initialize(argv)
:log => 'log/thin.log',
:pid => 'tmp/pids/thin.pid',
:max_conns => Server::DEFAULT_MAXIMUM_CONNECTIONS,
:max_persistent_conns => Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
:max_persistent_conns => Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS,
:requires => []
}

parse!
Expand Down Expand Up @@ -116,9 +117,9 @@ def parser
opts.separator ""
opts.separator "Common options:"

opts.on_tail("-r", "--require FILE", "require the library") { |file| ruby_require file }
opts.on_tail("-D", "--debug", "Set debbuging on") { Logging.debug = true }
opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)") { Logging.trace = true }
opts.on_tail("-r", "--require FILE", "require the library") { |file| @options[:requires] << file }
opts.on_tail("-D", "--debug", "Set debbuging on") { @options[:debug] = true }
opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)") { @options[:trace] = true }
opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
opts.on_tail('-v', '--version', "Show version") { puts Thin::SERVER; exit }
end
Expand Down Expand Up @@ -157,6 +158,10 @@ def run_command
# relative to this one.
Dir.chdir(@options[:chdir]) unless CONFIGLESS_COMMANDS.include?(@command)

@options[:requires].each { |r| ruby_require r }
Logging.debug = @options[:debug]
Logging.trace = @options[:trace]

controller = case
when cluster? then Controllers::Cluster.new(@options)
when service? then Controllers::Service.new(@options)
Expand Down
3 changes: 3 additions & 0 deletions site/rdoc.rb
Expand Up @@ -217,6 +217,9 @@ module Page
<li><a href="/thin/download/">download</a></li>
<li><a href="/thin/usage/">usage</a></li>
<li><a href="/thin/doc/">doc</a></li>
<li><a href="http://github.com/macournoyer/thin/">code</a></li>
<li><a href="http://thin.lighthouseapp.com/projects/7212-thin/">bugs</a></li>
<li><a href="/thin/users/">users</a></li>
<li><a href="http://groups.google.com/group/thin-ruby/">community</a></li>
</ul>
<div id="sidebar">
Expand Down
25 changes: 22 additions & 3 deletions spec/runner_spec.rb
Expand Up @@ -13,7 +13,7 @@
Runner.new(%w(stop)).command.should == 'stop'
Runner.new(%w(restart)).command.should == 'restart'
end

it "should abort on unknow command" do
runner = Runner.new(%w(poop))

Expand Down Expand Up @@ -66,14 +66,33 @@
it "should warn when require a rack config file" do
STDERR.stub!(:write)
STDERR.should_receive(:write).with(/WARNING:/)

runner = Runner.new(%w(start -r config.ru))
runner.run! rescue nil

runner.options[:rackup].should == 'config.ru'
end

it "should require file" do
proc { Runner.new(%w(start -r unexisting)) }.should raise_error(LoadError)
runner = Runner.new(%w(start -r unexisting))
proc { runner.run! }.should raise_error(LoadError)
end

it "should remember requires" do
runner = Runner.new(%w(start -r rubygems -r thin))
runner.options[:requires].should == %w(rubygems thin)
end

it "should remember debug options" do
runner = Runner.new(%w(start -D -V))
runner.options[:debug].should be_true
runner.options[:trace].should be_true
end

it "should default debug and trace to false" do
runner = Runner.new(%w(start))
runner.options[:debug].should_not be_true
runner.options[:trace].should_not be_true
end
end

Expand Down

0 comments on commit a8ed858

Please sign in to comment.