Christian Klauser
2006-Apr-17 10:14 UTC
[Rails] Reload an application without restarting the Server?
Hi, I would like to set up a "shared hosting"-like rails environment on a linux (+Apache1.3 +FastCGI +MySQL) machine. As we all know, rails provides support for different environments. Now I would like to enable my "users" to switch individual applications between development and production mode. In theory, all they have to do is to add "ENV[''RAILS_ENV''] ||= ''production''" into their environment.rb. The problem is, that the production environment caches the rails application and once you have entered production mode you cannot switch back without killing the FastCGI processes or restarting the webserver. I know that its possible because the RailsFCGIHandler has methods called resart!, restore! and reload! that exactly that but they are private and I don''t know how to obtain a reference to RailsFCGIHandler from a Rails ActionController within that application. I would like to have some kind of reload script or an admin page with the button: "Reload Application"... (And no, I can''t just restart the server because its a shared hosting environment so there are other (non-rail/ruby) applications running on that same server) -- Posted via http://www.ruby-forum.com/.
Christian Klauser
2006-Apr-17 23:52 UTC
[Rails] Re: Reload an application without restarting the Server?
You mean, there is no way I can reload a production application without restarting the _whole_ server???? -- Posted via http://www.ruby-forum.com/.
Ray Baxter
2006-Apr-18 00:10 UTC
[Rails] Re: Reload an application without restarting the Server?
Christian Klauser wrote:> You mean, there is no way I can reload a production application without > restarting the _whole_ server????No need to restart the web server, check out script/process/reaper and spawner -- Ray
Steve Koppelman
2006-Apr-18 00:19 UTC
[Rails] Re: Reload an application without restarting the Server?
You could probably kill a given user''s FCGI processes with a shell script; new ones should get spawned as needed. Try that. I guess you could also have the production environments run in an individual Mongrel or Lighttpd instance that you proxy through Apache. Then the users could restart those to their hearts'' content. Just guessing. Still seems fishy to host a single instance of an app and switch it between development and production modes. I''d think most people would want to develop locally and only host the production version of the site, and that the remaining folks who can''t or won''t install MySQL and Rails on their own PC would want both environments available simultaneously so they don''t have to take down their site every time they want to develop. Christian Klauser wrote:> You mean, there is no way I can reload a production application without > restarting the _whole_ server????-- Posted via http://www.ruby-forum.com/.
Bryan Duxbury
2006-Apr-18 01:54 UTC
[Rails] Re: Reload an application without restarting the Server?
Christian Klauser wrote:> You mean, there is no way I can reload a production application without > restarting the _whole_ server????The other way to do it would be to use like "ps -A | grep /username/appname/dispatch.fcgi" then just kill those fcgi processes. I use a similar method to reload my app hosted on textdrive (www.miami-bid.com) when ever I do an svn-update. The exact syntax of that would be a little complicated, probably, but perfectly doable. -- Posted via http://www.ruby-forum.com/.
Christian Klauser
2006-Apr-18 09:38 UTC
[Rails] Re: Reload an application without restarting the Server?
Thanks for the answers. You saved my day! :-) Steve Koppelman wrote:> I guess you could also have the production environments run in an > individual Mongrel or Lighttpd instance that you proxy through Apache. > Then the users could restart those to their hearts'' content. Just > guessing.Might be an idea. I''ve never done that though.> Still seems fishy to host a single instance of an app and switch it > between development and production modes.I do plan to develop locally but at some point I would like to patches I''ve uploaded. Or maybe I can''t reproduce a bug locally so I would like to be able to run the web app in dev mode. Thank you guys! -- Posted via http://www.ruby-forum.com/.
michael lascarides
2006-Apr-18 16:02 UTC
[Rails] Re: Reload an application without restarting the Server?
>From the Agile book:> killall -USR1 dispatch.fcgidoes a graceful restart of all currently running fcgi processes on *nix. Always works for me. - michael. -- Posted via http://www.ruby-forum.com/.
Matt White
2006-Apr-18 16:43 UTC
[Rails] Re: Reload an application without restarting the Server?
I know this is probably going to sound like a broken record, but check out Capistrano. I use it on Textdrive (shared), and for multiple apps on my VPS, and it''s the easiest way to deploy/restart an app, especially if you''re already using SVN (which I also highly recommend). It can be a little bit of work to get it going, but now that I use it I can''t imagine deploying without it. It will automatically call reaper and spawner to restart your app for you. Matt On 4/18/06, michael lascarides <michael@electrotone.com> wrote:> > >From the Agile book: > > > killall -USR1 dispatch.fcgi > > does a graceful restart of all currently running fcgi processes on *nix. > Always works for me. > > - michael. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060418/1380d21d/attachment.html
Christian Klauser
2006-Apr-18 20:49 UTC
[Rails] Re: Re: Reload an application without restarting the Server?
Matt White wrote:> I know this is probably going to sound like a broken record, but check > out > Capistrano. I use it on Textdrive (shared), and for multiple apps on my > VPS, > and it''s the easiest way to deploy/restart an app, especially if you''re > already using SVN (which I also highly recommend). It can be a little > bit of > work to get it going, but now that I use it I can''t imagine deploying > without it. It will automatically call reaper and spawner to restart > your > app for you. > > MattHm... sounds useful too. I''ve never used subversion or CVS but that might be worth a try too. Thx! :-) -- Posted via http://www.ruby-forum.com/.
Christian Klauser
2006-Apr-20 01:55 UTC
[Rails] Re: Re: Reload an application without restarting the Server?
Christian Klauser wrote:> Matt White wrote: >> I know this is probably going to sound like a broken record, but check >> out >> Capistrano. I use it on Textdrive (shared), and for multiple apps on my >> VPS, >> and it''s the easiest way to deploy/restart an app, especially if you''re >> already using SVN (which I also highly recommend). It can be a little >> bit of >> work to get it going, but now that I use it I can''t imagine deploying >> without it. It will automatically call reaper and spawner to restart >> your >> app for you. >> >> Matt > > Hm... sounds useful too. I''ve never used subversion or CVS but that > might be worth a try too. Thx! :-)Ok... I''m still working on it but the main problem is, that I (=my shell account) don''t have permissions to kill (send any signals ot) the "dispatch.fcgi" processes... I haven''t trief capistrano yet but I bet it uses something like `kill -9 #{pid}` too... Please correct me if I''m wrong... -- Posted via http://www.ruby-forum.com/.