Created
November 20, 2012 01:08
-
-
Save atmos/4115286 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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