Skip to content
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

implement TSTP handling #492

Merged
merged 1 commit into from Apr 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/shoryuken/runner.rb
Expand Up @@ -19,7 +19,7 @@ class Runner
def run(options)
self_read, self_write = IO.pipe

%w(INT TERM USR1 TTIN).each do |sig|
%w(INT TERM USR1 TSTP TTIN).each do |sig|
begin
trap sig do
self_write.puts(sig)
Expand Down Expand Up @@ -106,6 +106,12 @@ def execute_soft_shutdown
exit 0
end

def execute_terminal_stop
logger.info { 'Received TSTP, will stop accepting new work' }

@launcher.stop
end

def print_threads_backtrace
Thread.list.each do |thread|
logger.info { "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}" }
Expand All @@ -123,8 +129,9 @@ def handle_signal(sig)
case sig
when 'USR1' then execute_soft_shutdown
when 'TTIN' then print_threads_backtrace
when 'TSTP' then execute_terminal_stop
when 'TERM', 'INT'
logger.info { "Received #{sig}, will shutdown down" }
logger.info { "Received #{sig}, will shutdown" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻


raise Interrupt
end
Expand Down