# Mongrel failing to start on bootup as PID files still exist

**URL:** <https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669>\
**Category:** Deployment\
**Created:** [May 21, 2007, 12:48pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669 "2007-05-21T12:48:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 12:48pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/1 "2007-05-21T12:48:15Z")

</div>

Hi,  
One of my site’s servers had a problem yesterday and the host  
restarted it. During boot up Mongrel failed to start as the PID files  
still existed in /log

I didn’t find out about this reboot until several hours later so the  
site was down that entire time which is less than ideal.

Does anybody know of a way around this? Is there a built in way to  
force Mongrel to start and overwrite any existing PID files?

I have the mongrel\_cluster startup script setup correctly btw.

Thanks in advance.

Regards,

Niall M.

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 6:35pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/2 "2007-05-21T18:35:31Z")

</div>

You could write init.d script to check if those files exist and if so  
delete them before trying to start up the cluster.

- Richard

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/3 "2007-05-21T20:39:51Z")

</div>

Thanks Richard, was thinking of doing that but was wondering if there  
was an existing solution, one built into Mongrel perhaps.

Niall M.

removed\_email\_address@domain.invalid wrote:

> > I didn’t find out about this reboot until several hours later so the
> > 
> > Niall M.
> 
> >

–  
Niall M.  
4L Communications Ltd.  
[http://www.4L.ie/](http://www.4L.ie/)

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/4 "2007-05-21T21:06:54Z")

</div>

> I have the mongrel\_cluster startup script setup correctly btw.  
> I usually write some shell script to clear out the pid files, but  
> another way that works is to have mongrel put it’s pid files in the /tmp  
> directory which gets emptied on restart.

–  
Daniel J.  
Systems Administrator

PLANET ARGON, LLC  
Ruby on Rails Development, Consulting & Hosting

> **[Planet Argon](https://www.planetargon.com)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[http://teknot.us](http://teknot.us) [blog]  
teknotus [freenode IRC]  
+1 503 445 2457  
+1 877 55 ARGON [toll free]  
+1 815 642 4068 [fax]

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 10:33pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/5 "2007-05-21T22:33:08Z")

</div>

or do it with --clean to mongrel\_cluster?

Vish

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 21, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/6 "2007-05-21T22:55:11Z")

</div>

Hi:

Install the mongrel\_cluster prerelease (soon to be released after I  
recover from RailsConf) and change your pidfile location to /var/run/  
mongrel\_cluster (on linux). Be sure to copy the new init.d script out  
of the gem source.

[http://blog.railsmachine.com/2007/2/26/mongrel\_cluster-prerelease-1-0-1-1](http://blog.railsmachine.com/2007/2/26/mongrel_cluster-prerelease-1-0-1-1)

Bradley

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 23, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/7 "2007-05-23T16:16:18Z")

</div>

Thanks for that Jim, will definitely look into both options.

And thanks for the other responses as well.

Niall

removed\_email\_address@domain.invalid wrote:

> Hello Niall – it looks like you have plenty of options for clearing  
> satisfied user.
> 
> Jim
> 
> >

–  
Niall M.  
4L Communications Ltd.  
[http://www.4L.ie/](http://www.4L.ie/)

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [June 20, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/8 "2007-06-20T23:21:36Z")

</div>

Niall M. wrote:

> Hi,  
> One of my site’s servers had a problem yesterday and the host  
> restarted it. During boot up Mongrel failed to start as the PID files  
> still existed in /log
> 
> I didn’t find out about this reboot until several hours later so the  
> site was down that entire time which is less than ideal.
> 
> Does anybody know of a way around this? Is there a built in way to  
> force Mongrel to start and overwrite any existing PID files?
> 
> I have the mongrel\_cluster startup script setup correctly btw.
> 
> Thanks in advance.
> 
> Regards,
> 
> Niall M.

On a related note.  
A script like this will kill any mongrel instance that is hanging around  
after its pid file is gone.  
#!/usr/local/bin/ruby

# 3000 is the port you wish to kill.

pid = `lsof -i :3000`.split("\n")[1].split()[1] rescue nil  
%x{kill -9 #{pid}} unless pid.nil?

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [June 20, 2007, 11:26pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/9 "2007-06-20T23:26:48Z")

</div>

Yeah look at this: [textsnippets.com](http://textsnippets.com/posts/show/931)

Works a treat!

----- Original Message -----  
From: “David H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, June 20, 2007 2:21 PM  
Subject: [Rails-deploy] Re: Mongrel failing to start on bootup as PID  
files  
still ex

---

<div class="post-metadata">

**Author:** ![Niall\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Niall\_M](https://www.ruby-forum.com/u/Niall_M)\
**Post date:** [May 23, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/mongrel-failing-to-start-on-bootup-as-pid-files-still-exist/104669/10 "2007-05-23T15:41:13Z")

</div>

On May 21, 5:46 am, Niall M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,  
> One of my site’s servers had a problem yesterday and the host  
> restarted it. During boot up Mongrel failed to start as the PID files  
> still existed in /log
> 
> I didn’t find out about this reboot until several hours later so the  
> site was down that entire time which is less than ideal.  
> Hello Niall – it looks like you have plenty of options for clearing  
> out those pesky PID files, but no one has addressed this part of your  
> email. Anything beyond a hobby site needs some sort of monitoring for  
> situations just like this. At RailsConf, Ezra specifically mentioned  
> using monit (which I currently use) to monitor one’s individual  
> mongrel processes. If that sounds like too much work, an excellent  
> alternative is the free Heartbeat website (http://  
> [heartbeat.highgroove.com/](http://heartbeat.highgroove.com/)) which allows you to monitor multiple  
> application URLs and email yourself when things go awry. I’d  
> encourage you to go sign up for heartbeat and see if using monit is  
> feasible for you. No financial connection to either one, just a very  
> satisfied user.

Jim
