# Starting Rails apps on server's reboot

**URL:** <https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806>\
**Category:** Rails\
**Created:** [October 31, 2007, 3:55am UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806 "2007-10-31T03:55:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 3:55am UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/1 "2007-10-31T03:55:36Z")

</div>

Hello list,

I’ve got a server with several Rails application running under mongrel.  
It  
works fine, but the problem is when I reboot it. Having to go to each  
app’s  
dir and restart mongrel is a pain, so I would like to know if there’s  
already something (maybe a rake task or bash script) that solves this  
problem? If not, what would be the recommended way? A bash script?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 4:02am UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/2 "2007-10-31T04:02:36Z")

</div>

On Oct 30, 2007 7:55 PM, Marcelo de Moraes S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> >

Use whatever mechanism your OS uses for other services, likely an rc  
script.

Pat

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 4:41am UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/3 "2007-10-31T04:41:11Z")

</div>

Pat, thanks for the reply.

So basically I should add to the script a line to start mongrel for each  
Rails app I have on the server?

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 6:54am UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/4 "2007-10-31T06:54:56Z")

</div>

I use @reboot in cron:

@reboot cd /www/eq2guild/guildcorner/current && ./script/spin  
@reboot cd /www/blog/flame-blog/current && ./script/spin  
…

That starts the tasks as a user I choose (in my case, the user is  
named ‘webtoys’) and since cron starts very late in the OS boot  
process, things will generally be well up and running before my  
application starts.

Note that if you put them in an rc script, they might run as root  
unless you specifically ask them them not to. And then what happens  
if you mess up that file? Will the system still boot?

Running things in a crontab also has the advantage that anyone who can  
run the crontab command can set it up – no special root privs needed.

–Michael

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 2:31pm UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/5 "2007-10-31T14:31:11Z")

</div>

On Linux systems, aren’t daemon tools or runit a more attractive  
option? These have the added benefit of restarting Mongrel whenever  
it stops, regardless of the reason. I used to have this working using  
mongrel\_cluster, but I haven’t had it working right since switching to  
Capistrano 2.1. Cap2.1 doesn’t support the mongrel\_cluster gem, and I  
haven’t fully figured out everything necessary to make it work again.

I also have a backgroundrb task to restart.

Anyone have the magic for runit?

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 31, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/starting-rails-apps-on-servers-reboot/118806/6 "2007-10-31T13:21:25Z")

</div>

Hi Marcelo

In the Win2003 server environment, just set each mongrel service to  
start automatically.

CCH

> **[Rails... Rails... Rails](http://cch4rails.blogspot.com)**
>
> Chee Chong Hwa aka CCH, a Malaysian Chief Software Architect blogs on his experiences with Ruby on Rail running on Win2003 Server+Apache 2.26 environment since 2007. Flirted briefly with Ubuntu 9.04 in 2009. Since January 2017, now using RubyMine...

On Oct 31, 10:55 am, “Marcelo de Moraes S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
