Skip to content

Instantly share code, notes, and snippets.

@atmos
Created November 20, 2012 01:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atmos/4115286 to your computer and use it in GitHub Desktop.
Save atmos/4115286 to your computer and use it in GitHub Desktop.
def run!
pid = fork do
exec_pid = fork do
$0 = "heaven[#{Heaven.current_sha}] : executing deployment of #{application_name}"
out_file = File.new(log, "w")
STDIN.reopen("/dev/null")
STDOUT.reopen(out_file)
STDERR.reopen(out_file)
execute
end
tail_pid = fork do
$0 = "heaven[#{Heaven.current_sha}] : syslogging #{application_name}'s deploy number(#{number})"
File::Tail::Logfile.open(log, :backward => 10) do |log|
log.tail { |line| application.logger.info(line) }
end
end
$0 = "heaven[#{Heaven.current_sha}] : reaper process, waiting for process(#{exec_pid})"
Process.wait(exec_pid)
status = $?.exitstatus
Process.kill("TERM", tail_pid)
exit(status)
end
Process.detach(pid)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment