jimmycuadra/lita — pull request #3 by PatrickTulskie (2013-07-22 14:02:49+00:00)
Title: Added CLI support for Daemonization

This branch adds a daemonizer for Lita. Here's how it works...

If you supply a -d flag, Lita will do the following:

1. The process will fork itself.
2. The parent will attempt to write the forked process's pid if the existing pid file is missing, empty, or the process can be killed.
3. The parent process quits.
4. The forked process will redirect its log files (pid is "nil" in the child process after the fork).
5. The process then ignores HUP and INT while it runs (By default, Ruby will exit. Most web servers use these signals for config reloads or something along those lines).

There are additional flags to redirect the log files to locations of your choosing.

I've been running this in production for about a week now and it's been rock solid on CentOS. I also have a simple `init.d` script for CentOS that will allow you to control Lita but I have not included it at this time.

This is only the second daemonizer I've written so if there are any questions or concerns I'm all ears. I will admit though, that I'm not entirely sure how/what to test for this feature with RSpec since it's mostly lower level Unix code. I guess at the very least, it might be good to mention it in the README file.