Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created March 13, 2012 01:19
Show Gist options
  • Save jimmycuadra/2026000 to your computer and use it in GitHub Desktop.
Save jimmycuadra/2026000 to your computer and use it in GitHub Desktop.
Daemonize a process with Ruby
def daemonize_app
if RUBY_VERSION < "1.9"
exit if fork
Process.setsid
exit if fork
Dir.chdir "/"
STDIN.reopen "/dev/null"
STDOUT.reopen "/dev/null", "a"
STDERR.reopen "/dev/null", "a"
else
Process.daemon
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment