Skip to content

Commit

Permalink
implement TSTP handling (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowdave7 authored and phstc committed Apr 16, 2018
1 parent b424889 commit ec92ebd
Showing 1 changed file with 9 additions and 2 deletions.
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" }

raise Interrupt
end
Expand Down

0 comments on commit ec92ebd

Please sign in to comment.