Skip to content

Instantly share code, notes, and snippets.

@ng
Created August 16, 2009 08:13
Show Gist options
  • Save ng/168584 to your computer and use it in GitHub Desktop.
Save ng/168584 to your computer and use it in GitHub Desktop.
# run as daemon if they asked for it
if options[:detatch]
FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'pids'))
Process.daemon
pid = "#{RAILS_ROOT}/tmp/pids/vms_server.pid"
File.open(pid, 'w'){ |f| f.write(Process.pid) }
at_exit { File.delete(pid) if File.exist?(pid) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment