wip
This commit is contained in:
+15
-6
@@ -96,14 +96,23 @@ private ######################################################################
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Dir.chdir directory do
|
Dir.chdir directory do
|
||||||
PTY.spawn(process.command) do |stdin, stdout, pid|
|
IO.popen(process.command, "w+") do |pipe|
|
||||||
trap("SIGTERM") { Process.kill("SIGTERM", pid) }
|
trap("SIGTERM") do
|
||||||
until stdin.eof?
|
Thread.new do
|
||||||
info stdin.gets, process
|
begin
|
||||||
|
Process.kill("SIGTERM", pipe.pid)
|
||||||
|
Timeout.timeout(3) { Process.waitall }
|
||||||
|
rescue Timeout::Error
|
||||||
|
Process.kill("SIGKILL", pipe.pid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
until pipe.eof?
|
||||||
|
info pipe.gets, process
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue PTY::ChildExited, Interrupt, Errno::EIO, Errno::ENOENT
|
rescue Interrupt, Errno::EIO, Errno::ENOENT
|
||||||
begin
|
begin
|
||||||
info "process exiting", process
|
info "process exiting", process
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
@@ -120,7 +129,7 @@ private ######################################################################
|
|||||||
def terminate_gracefully
|
def terminate_gracefully
|
||||||
info "sending SIGTERM to all processes"
|
info "sending SIGTERM to all processes"
|
||||||
kill_all "SIGTERM"
|
kill_all "SIGTERM"
|
||||||
Timeout.timeout(3) { Process.waitall }
|
Timeout.timeout(5) { Process.waitall }
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
info "sending SIGKILL to all processes"
|
info "sending SIGKILL to all processes"
|
||||||
kill_all "SIGKILL"
|
kill_all "SIGKILL"
|
||||||
|
|||||||
Reference in New Issue
Block a user