# Deleting pid files on ubuntu restart due to power down

**URL:** <https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004>\
**Category:** Mongrel\
**Created:** [July 2, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004 "2008-07-02T15:33:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [July 2, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004/1 "2008-07-02T15:33:53Z")

</div>

hi guys

we are running a ubuntu machine as our demo server for serving Ruby on  
rails apps  
we are using mysql,nginx,mongrel for serving the sites.

the problem is if for any reason the power fails out and comes back  
mysql and nginx get started fine but mongrel does not work due to  
some pid(mongrel.8000.pid mongrel.8001.pid mongrel.8002.pid) files  
existing in log folder.

we then manually delete the files and start the cluster.

is there anyway we can check during reboot of ubuntu server for any  
existing pid  
files in log folder and delete them and then start the mongrel cluster.

thanks  
jags

---

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [July 2, 2008, 4:40pm UTC](https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004/2 "2008-07-02T16:40:35Z")

</div>

On Wed, Jul 2, 2008 at 6:33 AM, Jags R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the problem is if for any reason the power fails out and comes back

sounds like the first thing to do is get a UPS 🙂

> mysql and nginx get started fine but mongrel does not work due to  
> some pid(mongrel.8000.pid mongrel.8001.pid mongrel.8002.pid) files

> is there anyway we can check during reboot of ubuntu server for any  
> existing pid  
> files in log folder and delete them and then start the mongrel cluster.

Of course – look in /etc/init.d for examples of scripts that are run at  
boot time (and/or shutdown).

Write your own and link it to the appropriate run-level (rc\*.d)  
directory.

FWIW,

---

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [July 2, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004/3 "2008-07-02T17:04:19Z")

</div>

New mongrel’s versions has the parameter “–clean”. It do the work 🙂

Jags R. escribiÃ³:

---

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [July 2, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/deleting-pid-files-on-ubuntu-restart-due-to-power-down/142004/4 "2008-07-02T17:11:24Z")

</div>

Ubuntu and debian mount /var/run/ directories using tmpfs, which means  
the  
/var/run directories are cleared out at boot time. That’s why debian  
packages write out pid files into subdirectories of /var/run. You might  
be  
able to configure your mongrel so that the pid files are written under  
/var/run

–Brian

2008/7/2 Rafael G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
