I would like to restart my rails application from within application. On demand. But I am stucked on first step. How to exit. exit 0 doesn''t work. I am running webrick or mongrel. by TheR -- Posted via http://www.ruby-forum.com/.
What do you mean by "restarting" the application? Do you mean end the session (if any) and (re)display the login/index/initial page? If you need to end a session you can do it with this: reset_session To send a user to the login/index/initial page you can just use a redirect: redirect_to :controller => ''my_controller'', :action => ''my_action'' Both things are done in your controllers. On Oct 13, 3:19 am, Damjan Rems <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I would like to restart my rails application from within application. On > demand. But I am stucked on first step. How to exit. exit 0 doesn''t > work. > > I am running webrick or mongrel. > > by > TheR > -- > Posted viahttp://www.ruby-forum.com/.
pepe wrote:> What do you mean by "restarting" the application? Do you mean end the > session (if any) and (re)display the login/index/initial page? > > If you need to end a session you can do it with this: > > reset_session > > To send a user to the login/index/initial page you can just use a > redirect: > > redirect_to :controller => ''my_controller'', :action => ''my_action'' > > Both things are done in your controllers. > > On Oct 13, 3:19�am, Damjan Rems <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>I would like to quit (kill) session. Just like pressing Ctrl+C. by TheR -- Posted via http://www.ruby-forum.com/.
Is the kill from outside application the only solution? by TheR -- Posted via http://www.ruby-forum.com/.
I don''t think you''ll be able to do that. I am assuming that you mean the user being able to kill the application. Remember that the user will probably be removed from the server that runs Rails and he/she won''t have access to it. That access is only available through the browser. The only way that you''ll be able to do something like that will be to provide a Logout link or something like that and make it available through a main layout so it''s present in all views. If what you want to do is to be able to stop the session from the server itself you''ll have to figure out who the user is that you want to end the session for and have a way of managing the sessions for all users (database store?), then you could kill the session any way you want (removing data from the DB for the session?). That won''t buy you much, though, if the user can still Login and keep going. On Oct 14, 4:01 am, Damjan Rems <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Is the kill from outside application the only solution? > > by > TheR > -- > Posted viahttp://www.ruby-forum.com/.
chris.reister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Oct-14 15:30 UTC
Re: How to exit rails application from within
On Oct 13, 11:56 am, Damjan Rems <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> pepe wrote: > > What do you mean by "restarting" the application? Do you mean end the > > session (if any) and (re)display the login/index/initial page? > > > If you need to end a session you can do it with this: > > > reset_session > > > To send a user to the login/index/initial page you can just use a > > redirect: > > > redirect_to :controller => ''my_controller'', :action => ''my_action'' > > > Both things are done in your controllers. > > > On Oct 13, 3:19 am, Damjan Rems <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > I would like to quit (kill) session. Just like pressing Ctrl+C. > > by > TheR > > -- > Posted viahttp://www.ruby-forum.com/.If you are running inside mongrels with monit I am sure you could really do this quite easily... controller: def restart `sudo monit restart -g mongrel all << server_sudo_password` end view: <% link_to "Restart", :action => :restart %> Of course because you CAN do something does not mean you SHOULD... requires you put the sudo password in the code BAD BAD... I have not tested it, because my dev system is not setup this way. but looks like it would work.
chris.reister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> On Oct 13, 11:56�am, Damjan Rems <rails-mailing-l...-ARtvInVfO7m5VldFQK4jKA@public.gmane.orgt> > wrote: >> >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > If you are running inside mongrels with monit I am sure you could > really do this quite easily... > > controller: > def restart > `sudo monit restart -g mongrel all << server_sudo_password` > end > > view: > <% link_to "Restart", :action => :restart %> > > Of course because you CAN do something does not mean you SHOULD... > requires you put the sudo password in the code BAD BAD... > > I have not tested it, because my dev system is not setup this way. > but looks like it would work.Sadly my server is Windows. I am working on an application for internal users which runs Word and Excel with ole automation a lot to provide output documents in pdf. I haven''t yet had production loads but a lot of things can go wrong when running ole automation. So I thought If I could close session and restart it on demand .... ( You can always repair windows by restarting it ;-) I thought that Mongrel or Webrick have some interface to end itself. Thank you TheR -- Posted via http://www.ruby-forum.com/.
Damjan Rems wrote: [...]> Sadly my server is Windows. I am working on an application for internal > users which runs Word and Excel with ole automation a lot to provide > output documents in pdf.There are better ways to build PDF files. If you can tell us a bit more about what you''re doing, perhaps we can make suggestions...> > I haven''t yet had production loads but a lot of things can go wrong when > running ole automation. So I thought If I could close session and > restart it on demand .... ( You can always repair windows by restarting > it ;-)I think you may be anticipating a problem that may or may not exist. Why don''t you test it out and see if you need this feature?> > I thought that Mongrel or Webrick have some interface to end itself. > > Thank you > TheRBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser wrote:> Damjan Rems wrote: > [...] >> Sadly my server is Windows. I am working on an application for internal >> users which runs Word and Excel with ole automation a lot to provide >> output documents in pdf. > > There are better ways to build PDF files. If you can tell us a bit more > about what you''re doing, perhaps we can make suggestions... > >> >> I haven''t yet had production loads but a lot of things can go wrong when >> running ole automation. So I thought If I could close session and >> restart it on demand .... ( You can always repair windows by restarting >> it ;-) > > I think you may be anticipating a problem that may or may not exist. > Why don''t you test it out and see if you need this feature? > >> >> I thought that Mongrel or Webrick have some interface to end itself. >> >> Thank you >> TheR > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgI would use something like god (http://god.rubyforge.org/) to watch the application for memory problems and the like. You could easily use this daemon to check for a "restart.txt" file and if it exists: 1. erase the file 2. restart application Your restart method in the controller is just: def restart File.open(''restart.txt'',''wb'') {} end and don''t forget the equivalent of before_filter :check_is_admin, :only => [:restart] Without a daemon running, you can crash your app fine but it will lay down dead without any hope for resurection... Gaspard -- Posted via http://www.ruby-forum.com/.