[Mongrel] can't configure mongrel_cluster to start on boot

David Vrensk david at vrensk.com
Tue Nov 6 18:48:11 EST 2007

On 11/5/07, Tiberiu Motoc <tiberiu.motoc at gmail.com> wrote:
> Hi everyone,

Hello Tiberiu,

I'm not sure if I can solve your problem, but I hope I can shed some light
on what's going on during boot time.

I've been working with Mongrel, Mongrel_cluster and Apache and it is great.
> However, I can't get mongrel_cluster to start at boot time. I followed the
> instructions from  http://mongrel.rubyforge.org/docs/mongrel_cluster.html (On
> Boot Initialization Setup) and mongrel_cluster does not start after
> rebooting the machine.
> I made sure that the shebang line is correct and I also made sure that the
> mongrel_cluster_ctl location is in the PATH variable. Just to be on the safe
> side I created a symbolic link in /usr/bin and still no luck.

When you installed the gem, you should have gotten mongrel_cluster_ctl in
/usr/bin.  If you didn't, you will definately need a symlink, since PATH is
very limited during boot (typically "/bin:/usr/bin:/sbin:/usr/sbin").  What
version of mongrel and mongrel_cluster are you using (run 'gem list

The next thing I did was to trace the mongrel_cluster script. There is
> something strange about it, and I can't believe that nobody complained about
> it yet: the script takes an argument (start, stop or restart), but the
> instructions provided on the mongrel_cluster webpage do not pass any
> argument(s) to it. So, how is the script supposed to start?

The 'mongrel_cluster' script found in "
/path/to/mongrel_cluster_gem/resources/mongrel_cluster" that the
instructions tell you to copy to /etc/init.d is a normal init.d script.  It
can be run directly by you (as root):

# /etc/init.d/mongrel_cluster stop

or through the 'service' helper (still as root or sudo)

$ sudo service mongrel_cluster start

When you ran 'chkconfig --level 345 mongrel_cluster', chkconfig created
symlinks in the directories /etc/rc0.d, /etc/rc1.d, up to /etc/rc6.d.  In
rc3.d, rc4.d and rc5.d there are symlinks named S85mongrel_cluster that tell
the system (specifically the script '/etc/rc') to run the script with the
argument 'start' (S for start) and in rc0.d etc, there is K15mongrel_cluster
which the system will take as a signal to run the script with 'stop' (K for
kill).  So there is the magic and the reason noone has complained about the
script.  It is good the way it is.

What about when the machine gets shut down, where in the script do we delete
> the mongrel pid files?

When the machine is shut down, mongrel_cluster will be run with 'stop', and
mongrel_cluster_ctl will take care of the pid files.

(or worse, if it gets powered off, and if we restart without deleting the
> pid files, then the script won't even start the mongrel processes).

That was a problem in and earlier release of mongrel_cluster (the gem, not
the script).  Now it actually peeks inside the pid files, and if it can't
find the processes listed there, it will remove the pid files and proceed.

As I said, this will not solve your problem, but perhaps it tells you where
you should start looking.  I can recommend the man pages for 'init' and
'inittab' to better understand what's going on.  And everyone should read
the source of /etc/rc at least once; it's short and dispels a lot of magic.

Good luck, and tell us about your findings!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20071107/1a8a6742/attachment-0001.html 

More information about the Mongrel-users mailing list