From: Brian Candler Date: 2009-02-19T23:25:20+09:00 Subject: Re: a little daemon daemonizes, but hangs the logout Jeff Moore wrote: > There is a perfectly serviceable Daemon class in lib/webrick/server.rb > as well. > > You can use it as is, or as a template for your own code. And there is this one from rackup (part of the rack package) if daemonize if RUBY_VERSION < "1.9" exit if fork Process.setsid exit if fork Dir.chdir "/" File.umask 0000 STDIN.reopen "/dev/null" STDOUT.reopen "/dev/null", "a" STDERR.reopen "/dev/null", "a" else Process.daemon end if pid File.open(pid, 'w'){ |f| f.write("#{Process.pid}") } at_exit { File.delete(pid) if File.exist?(pid) } end end -- Posted via http://www.ruby-forum.com/.