# Can't configure mongrel\_cluster to start on boot

**URL:** <https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211>\
**Category:** Mongrel\
**Created:** [November 5, 2007, 12:31am UTC](https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211 "2007-11-05T00:31:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [November 5, 2007, 12:31am UTC](https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211/1 "2007-11-05T00:31:50Z")

</div>

Hi everyone,

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](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.

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? I’m not an  
expert on Linux admin, but is the chkconfig application supposed to pass  
“start” to the script? What about when the machine gets shut down, where  
in  
the script do we delete the mongrel 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).

Anyway, those are small things that can be easily changed in the script,  
so  
I hardcoded “start” in the script, and my script failed on the following  
line:  
which mongrel\_cluster\_ctl \>/dev/null || exit 0  
I commented out the line and provided the full path to  
mongrel\_cluster\_ctl.  
I dumped the $RETVAL into a log file (after calling mongrel\_cluster\_ctl)  
and  
it was 137.

I don’t know what else to do. I am logged in as admin, I successfully  
used  
chkconfig to add Apache to the boot script, and if I run the script  
manually

- it works!

Thanks,  
Tiberiu

---

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [November 7, 2007, 12:48am UTC](https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211/2 "2007-11-07T00:48:51Z")

</div>

On 11/5/07, Tiberiu M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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  
mongrel’)?

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!

/David

---

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [November 7, 2007, 9:13pm UTC](https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211/3 "2007-11-07T21:13:41Z")

</div>

Hi David,

Thanks for all your help. It now makes sense how it all works.  
Unfortunately  
for me it doesn’t work and I don’t think it is because of  
mongrel\_cluster.

After you mentioned that I should have a symbolic link to  
mongrel\_cluster\_ctl in /usr/bin, I realized that maybe the whole Ruby  
environment is not available at boot time. I installed Ruby in a shared  
location, but there are not symbolic links in /usr/bin to any of the  
Ruby  
utilities.

To test this, I created a small Ruby script which write “TEST” to a file  
in  
/tmp; I call this script from a bash script which I put in the  
/etc/init.d  
directory and which I configured using /sbin/chkconfig (similar to the  
setup  
of mongrel\_cluster). Guess what?! No file is created in the /tmp  
directory  
at boot time.

So now my question becomes: what is the proper way of installing Ruby on  
a  
Linux machine? I did create a symbolic link to “ruby” in /usr/bin, but I  
don’t think that’s enough. What other symbolic links do I need?

Thanks,  
Tiberiu

---

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [November 8, 2007, 4:52pm UTC](https://www.ruby-forum.com/t/cant-configure-mongrel-cluster-to-start-on-boot/119211/4 "2007-11-08T16:52:44Z")

</div>

On Nov 7, 2007 9:13 PM, Tiberiu M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi David,
> 
> Thanks for all your help. It now makes sense how it all works.

Hi Tiberiu, thanks, I’m glad to hear that!

> Unfortunately for me it doesn’t work and I don’t think it is because  
> of mongrel\_cluster.
> 
> After you mentioned that I should have a symbolic link to  
> mongrel\_cluster\_ctl in /usr/bin,

Oops, did I say that? I meant to say that the actual script  
‘mongrel\_cluster\_ctl’ should reside in /usr/bin. But I have to admit  
that  
that was a simplification; the script should reside in the same  
directory as  
the ‘ruby’ binary.

I realized that maybe the whole Ruby environment is not available at  
boot

> time. I installed Ruby in a shared location, but there are not symbolic  
> links in /usr/bin to any of the Ruby utilities.

Well, there needn’t be. You can have you entire ruby installation in  
/usr/local or /what/ever, as long as you put /usr/local/bin or  
/what/ever/bin in your path. Where is that shared location? How do you  
access it? The reason I ask is that mongrel\_cluster normally starts  
after  
all network services have been started. A typical FC6 box would have  
this  
(and more) in /etc/rc3.d:

S10network (starts the network interface)  
S25netfs (mounts remote shares)  
S28autofs (starts the automounter)  
S60nfs (starts nfs sharing)  
S85mongrel\_cluster

And since the scripts are run in this order, remote shares should be  
available.

To test this, I created a small Ruby script which write “TEST” to a  
file in

> /tmp; I call this script from a bash script which I put in the /etc/init.d  
> directory and which I configured using /sbin/chkconfig (similar to the setup  
> of mongrel\_cluster). Guess what?! No file is created in the /tmp directory  
> at boot time.

Just to check: if you put

echo TEST \> /tmp/my\_test\_script\_runs

in the bash script, does that work as expected? And second, do you call  
the  
ruby script as a command or a script, i.e., do you say

my\_script

or

ruby my\_script

And finally, what does the script look like?

So now my question becomes: what is the proper way of installing Ruby  
on a

> Linux machine? I did create a symbolic link to “ruby” in /usr/bin, but I  
> don’t think that’s enough. What other symbolic links do I need?

You don’t need any symbolic links as long as the bin directory is in  
your  
path. If you compile it on your own, it’s quite common to put it  
/usr/local  
since that is what ‘configure’ does by default.

The ‘proper’ way is a matter of taste. If you enjoy being an admin, go  
ahead and install everything from source and put it in /usr/local. If  
you  
don’t, use your distro’s package manager (yum, dep, apt, rpm, what have  
you)  
and let it put things in /usr. Arguing about which is best borders on  
philosophy.

I still don’t have a solution for you, but keep talking!

Good luck,

/David
