Dynamically Restarting a Rails App?

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 Burns
Wisconsin ARNG

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

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 Burns
Wisconsin ARNG

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.