# Dynamically Restarting a Rails App?

**URL:** <https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018>\
**Category:** Rails\
**Created:** [July 31, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018 "2009-07-31T12:51:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [July 31, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018/1 "2009-07-31T12:51:43Z")

</div>

Hello all,

Is there a way to restart a Rails app from a controller? I’m trying to  
make it so that, in the backend, administrators can add plugins/themes/  
etc. to the running application without the need to actually go in to  
the server and restart the app. My first thought on this would be to  
just have the app restart on the next request after say, a plugin was  
activated. Has anyone done this before, or am I not taking the right  
approach?

Cheers,  
SPC Anthony B.  
Wisconsin ARNG

---

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [July 31, 2009, 12:57pm UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018/2 "2009-07-31T12:57:34Z")

</div>

On Jul 31, 4:16 am, Anthony B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello all,
> 
> Is there a way to restart a Rails app from a controller? I’m trying to  
> make it so that, in the backend, administrators can add plugins/themes/  
> etc. to the running application without the need to actually go in to  
> the server and restart the app. My first thought on this would be to  
> just have the app restart on the next request after say, a plugin was  
> activated. Has anyone done this before, or am I not taking the right  
> approach?

well there’s no builtin way of doing this, but i don’t see why you  
couldn’t shell out and `monit restart ...` (assuming monit was  
controlling your processes, replace as appropriate depending on your  
deploying (eg touch tmp/restart.txt for passenger).  
it’s not very nice but would probably work. The obvious downside I can  
think of is that if the administrator doesn’t have shell access to the  
server they could completely screw themselves without being able to  
fix it (eg accidentally add a plugin that is broken or incompatible  
with the app or the version of rails used)

Fred

---

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [August 1, 2009, 10:22am UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018/3 "2009-08-01T10:22:58Z")

</div>

On Jul 31, 1:56 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > approach?
> 
> Fred

Hmm… Doing it via the shell isn’t really an option. The touch tmp/  
restart.txt way is the only way I can figure out so far that I can  
call from the controller. I don’t want to require the user to use any  
monitoring apps or anything outside the application. I’m trying to  
make it as easy as possible for the user to install plugins, custom  
permalinks, etc. without requiring them to manually restart the app.  
Now the tmp/restart.txt method would work on mod\_rails but there’s  
still people out there using other server technologies that I’d need  
to do something different?

Cheers,  
SPC Anthony B.  
Wisconsin ARNG

---

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [August 1, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018/4 "2009-08-01T17:26:41Z")

</div>

On Aug 1, 12:08 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > permalinks, etc. without requiring them to manually restart the app.  
> > Now the tmp/restart.txt method would work on mod\_rails but there’s  
> > still people out there using other server technologies that I’d need  
> > to do something different?
> 
> There’s no one size fits all. Different deployments handle this in  
> different ways and typically rails isn’t aware of how it’s deployed  
> (another complication would be if the app was hosted across several  
> machines)
> 
> Fred

I guess that would bring me to my next question. Besides restarting  
the Rails application itself, is there a way I can load my plugins/  
routes/etc. into the application once it’s running? My whole dilemma  
here is to allow Rails to do the same as say, a PHP application like  
WordPress does, with one-click plugin activation.

---

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [August 1, 2009, 11:09am UTC](https://www.ruby-forum.com/t/dynamically-restarting-a-rails-app/173018/5 "2009-08-01T11:09:14Z")

</div>

On Aug 1, 9:21 am, Anthony B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> still people out there using other server technologies that I’d need  
> to do something different?

There’s no one size fits all. Different deployments handle this in  
different ways and typically rails isn’t aware of how it’s deployed  
(another complication would be if the app was hosted across several  
machines)

Fred
