Commit 91dce34f by Calen Pennington

Be more graceful when terminating background processes

parent 352a4da5
...@@ -37,6 +37,15 @@ def background_process(*command) ...@@ -37,6 +37,15 @@ def background_process(*command)
pgid = Process.getpgid(pid) pgid = Process.getpgid(pid)
begin begin
Timeout.timeout(5) do Timeout.timeout(5) do
puts "Interrupting process group #{pgid}"
Process.kill(:SIGINT, -pgid)
puts "Waiting on process group #{pgid}"
Process.wait(-pgid)
puts "Done waiting on process group #{pgid}"
end
rescue Timeout::Error
begin
Timeout.timeout(5) do
puts "Terminating process group #{pgid}" puts "Terminating process group #{pgid}"
Process.kill(:SIGTERM, -pgid) Process.kill(:SIGTERM, -pgid)
puts "Waiting on process group #{pgid}" puts "Waiting on process group #{pgid}"
...@@ -51,6 +60,7 @@ def background_process(*command) ...@@ -51,6 +60,7 @@ def background_process(*command)
puts "Done waiting on process group #{pgid}" puts "Done waiting on process group #{pgid}"
end end
end end
end
end end
def environments(system) def environments(system)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment