What is the proper way to create a well-behaved Unix or Linux daemon in Ruby?
What is the definition of a well-behaved daemon anyway, and how would one write such a program in Ruby?
What is the proper way to create a well-behaved Unix or Linux daemon in Ruby?
What is the definition of a well-behaved daemon anyway, and how would one write such a program in Ruby?
Following on from Jason's awesome response I have written a fuller implementation here:
https://gist.github.com/1372491/b76b60fb1842bf0507f47869ab19ad50a045b214
I have implemented logging in addition to the double fork and writing of the pid to file.
Another interesting implementation is in Unicorn:
https://github.com/defunkt/unicorn/blob/master/lib/unicorn/launcher.rb