diff --git a/lib/thin/controllers/controller.rb b/lib/thin/controllers/controller.rb index 09eaf96a..ad679ea3 100644 --- a/lib/thin/controllers/controller.rb +++ b/lib/thin/controllers/controller.rb @@ -91,7 +91,7 @@ def stop raise OptionRequired, :pid unless @options[:pid] tail_log(@options[:log]) do - if Server.kill(@options[:pid], @options[:force] ? 0 : (@options[:timeout] || 60)) + if Server.kill(@options[:pid], (@options[:timeout] || 60), force: @options[:force]) wait_for_file :deletion, @options[:pid] end end diff --git a/lib/thin/daemonizing.rb b/lib/thin/daemonizing.rb index aa0dbfe0..df3e568e 100644 --- a/lib/thin/daemonizing.rb +++ b/lib/thin/daemonizing.rb @@ -104,8 +104,8 @@ module ClassMethods # PID is stored in +pid_file+. # If the process is still running after +timeout+, KILL signal is # sent. - def kill(pid_file, timeout=60) - if timeout == 0 + def kill(pid_file, timeout=60, force: false) + if force send_signal('INT', pid_file, timeout) else send_signal('QUIT', pid_file, timeout) diff --git a/spec/controllers/controller_spec.rb b/spec/controllers/controller_spec.rb index f0ec6095..d3c95652 100644 --- a/spec/controllers/controller_spec.rb +++ b/spec/controllers/controller_spec.rb @@ -107,10 +107,16 @@ end it "should stop" do - Server.should_receive(:kill).with('thin.pid', 10) + Server.should_receive(:kill).with('thin.pid', 10, force: nil) @controller.stop end - + + it "should force stop" do + @controller.options[:force] = true + Server.should_receive(:kill).with('thin.pid', 10, force: true) + @controller.stop + end + it "should restart" do Server.should_receive(:restart).with('thin.pid') @controller.restart diff --git a/spec/daemonizing_spec.rb b/spec/daemonizing_spec.rb index 50e906a6..cfc4681f 100644 --- a/spec/daemonizing_spec.rb +++ b/spec/daemonizing_spec.rb @@ -110,7 +110,7 @@ def name timeout(10) do silence_stream STDOUT do - TestServer.kill(@server.pid_file, 0) + TestServer.kill(@server.pid_file, 60, force: true) end end