Compare commits

...
7 Commits
Author SHA1 Message Date
David Dollar 7bb1e58879 0.8.0 2010-09-20 16:22:31 -04:00
David Dollar 62b6cac741 print message when signal received 2010-09-20 16:22:13 -04:00
Keith Rarick 2a7dadc2b2 Wait cleanly for child processes to exit.
Signed-off-by: David Dollar <ddollar@gmail.com>
2010-09-20 16:21:41 -04:00
David Dollar 9cd772ac0f 0.7.5 2010-09-17 09:31:24 -04:00
David Dollar 2b27d0a51a include files from export in the gem 2010-09-17 09:31:08 -04:00
Keith Rarick 99204d7c1d Wait for descendant processes to exit. 2010-09-17 21:28:01 +08:00
Ricardo Chimal, Jr e9b5ed81b8 bugfix upstart export erb templates 2010-09-17 21:27:29 +08:00
4 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -3,4 +3,4 @@ stop on stopping <%= app %>-<%= process.name %>
respawn respawn
chdir <%= engine.directory %> chdir <%= engine.directory %>
exec su <%= user %> -c "PORT=<%= port %> <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1" exec su - <%= user %> -c 'export PORT=<%= port %>; <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1'
+1
View File
@@ -9,4 +9,5 @@ Parka::Specification.new do |gem|
gem.executables = "foreman" gem.executables = "foreman"
gem.files << "man/foreman.1" gem.files << "man/foreman.1"
gem.files << Dir["export/**/*"]
end end
+1 -1
View File
@@ -1,6 +1,6 @@
module Foreman module Foreman
VERSION = "0.7.3" VERSION = "0.8.0"
class AppDoesNotExist < Exception; end class AppDoesNotExist < Exception; end
+7 -7
View File
@@ -39,8 +39,8 @@ class Foreman::Engine
fork process, options fork process, options
end end
trap("TERM") { kill_and_exit("TERM") } trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
trap("INT") { kill_and_exit("INT") } trap("INT") { puts "SIGINT received"; kill_all("INT") }
watch_for_termination watch_for_termination
end end
@@ -48,8 +48,8 @@ class Foreman::Engine
def execute(name, options={}) def execute(name, options={})
fork processes[name], options fork processes[name], options
trap("TERM") { kill_and_exit("TERM") } trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
trap("INT") { kill_and_exit("INT") } trap("INT") { puts "SIGINT received"; kill_all("INT") }
watch_for_termination watch_for_termination
end end
@@ -100,13 +100,12 @@ private ######################################################################
end end
end end
def kill_and_exit(signal="TERM") def kill_all(signal="TERM")
info "terminating" info "terminating"
running_processes.each do |pid, process| running_processes.each do |pid, process|
info "killing #{process.name} in pid #{pid}" info "killing #{process.name} in pid #{pid}"
Process.kill(signal, pid) Process.kill(signal, pid)
end end
exit 0
end end
def info(message, process=nil) def info(message, process=nil)
@@ -149,7 +148,8 @@ private ######################################################################
pid, status = Process.wait2 pid, status = Process.wait2
process = running_processes.delete(pid) process = running_processes.delete(pid)
info "process terminated", process info "process terminated", process
kill_and_exit kill_all
Process.waitall
end end
def running_processes def running_processes