Skip to content

Do not wait indefinitely for process to finish #326

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 1 commit 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/thin/controllers/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/thin/daemonizing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions spec/controllers/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/daemonizing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down