Ok, so I would like to create an action in Rails to restart itself. I did a little searching and found:
http://snippets.dzone.com/posts/show/5002
Which suggests
Ok I found a fix... I changed how I start rails to:
mongrel_rails start -d
and now the following action will do it:
def restart
fork { exec "mongrel_rails restart" }
redirect_to "/server_maintenance"
end
As a caveat, the redirect_to will cause a failed load because the server will be down... however a reload after a pause will show that the restart was successful. This could be fixed by changing the restart to be done with AJAX, followed by a javascript reload... but I will leave that as an exercise to the reader.