More elegant Mongrel restarts

Posted by & filed under Ruby on Rails.

Having explained our hack for bringing back Mongrel after a server crash, I discovered that our hosting company has a different approach. Their method has the advantage of not requiring scripts with hard-coded paths; on the other hand, it does require you to patch Mongrel itself, which makes things interesting come upgrade time. (On the other hand, the hypothetical Mongrel update may incorporate this patch, or avoid the problem some other way.)

Their method patches Mongrel to test whether the processes enumerated in the PID file(s) are actually still running. If the process is dead (that is, the PID file belongs to a Mongrel instance which died in a server crash,) the file is declared “stale” and cleared, allowing Mongrel to start up properly; if the process exists, the PID file is not stale, and Mongrel aborts startup as it was originally designed.

The method is detailed here (scroll down to the heading, “Stale PID files preventing Mongrel to start up,” ungrammatical though it may be.)

Leave a Reply

You must be logged in to post a comment.