Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jpalumickas/4719115 to your computer and use it in GitHub Desktop.
Save jpalumickas/4719115 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