This page has notes about our research into Ruby programming, specifically how to keep a Ruby program running consistently and ready for incoming requests.
== Serv-O-Lux
http://github.com/TwP/servolux
Serv-O-Lux is a collection of Ruby classes that are useful for daemon and process management, and for writing your own Ruby services. The code is well documented and tested.
== Ideas from Rubyists
http://archive.codehaus.org/lists/org.codehaus.jruby.user/msg/1a2dd4710909220913l1d64a70qfa4a88e9f37710ff@mail.gmail.com
Run your script with nohup and there you have your daemon. I also use
this kind of skeleton in the "daemon script" itself.
File.open(PID_FILE, "w") { |f| f << $$ }
def clean_up!
FileUtils.rm PID_FILE
end
Signal.trap 15 { clean_up! }
begin
....
ensure
clean_up!
end
Making a daemon in MRI is straight forward: fork a process and hand off control to the init process. Since JRuby doesn't do forking, I'm curious how people are handling this. The consensus seems to be running some script in the background with "nohup". Example:
GlassFish gem supports daemonizing on linux and solaris platforms. Just run glassfish with -d flag.
See http://archive.codehaus.org/lists/org.codehaus.jruby.user/msg/d38669d10909221428kcc6e4cehec26224f8ccb124a@mail.gmail.com
Start-Stop Daemon
Start-Stop daemon: A standard Debian distribution contains the useful start-stop-daemon in the directory /sbin. It is used to start program as dameon when this program are not designed (or packaged) in this way.
See http://www.univ-orleans.fr/lifo/Members/Jean-Francois.Lalande/doku.php?id=system:start-stop-daemon