Is there any way to request WEBrick to shutdown besides hitting CTRL-C at the console? I''m looking for, perhaps, a script/shutdown command, or perhaps a special URL that will request WEBrick to die. It can be a command run in a different shell, or, as I said, a special URL. Anyone? Tom Harris Cisco Systems -- Posted via http://www.ruby-forum.com/.
Tom Harris wrote:> Is there any way to request WEBrick to shutdown besides hitting CTRL-C > at the console?What OS are you running on? -- Posted via http://www.ruby-forum.com/.
killall On 1/14/06, Tom Harris <tom@tharrisx.homedns.org> wrote:> Is there any way to request WEBrick to shutdown besides hitting CTRL-C > at the console?kill -9 `ps aux | grep ''script/server'' | awk ''{print $2}''`
On 1/14/06, Joe Van Dyk <joevandyk@gmail.com> wrote:> killallwhoops, ignore that first line.> On 1/14/06, Tom Harris <tom@tharrisx.homedns.org> wrote: > > Is there any way to request WEBrick to shutdown besides hitting CTRL-C > > at the console? > > kill -9 `ps aux | grep ''script/server'' | awk ''{print $2}''`Or were you looking for something else?
Joe Van Dyk wrote:> On 1/14/06, Joe Van Dyk <joevandyk@gmail.com> wrote: >> killall > whoops, ignore that first line. > >> On 1/14/06, Tom Harris <tom@tharrisx.homedns.org> wrote: >> > Is there any way to request WEBrick to shutdown besides hitting CTRL-C >> > at the console? >> >> kill -9 `ps aux | grep ''script/server'' | awk ''{print $2}''` > > Or were you looking for something else?I''m on Windows. Tom -- Posted via http://www.ruby-forum.com/.
on windows, you can do, > taskkill /F /IM ruby.exe taskkill can be run remotely, too. Tom Harris wrote:> Is there any way to request WEBrick to shutdown besides hitting CTRL-C > at the console? > > I''m looking for, perhaps, a script/shutdown command, or perhaps a > special URL that will request WEBrick to die. > > It can be a command run in a different shell, or, as I said, a special > URL. > > Anyone? > > Tom Harris > Cisco Systems
Lou Vanek wrote:> on windows, you can do, > > > taskkill /F /IM ruby.exe > > taskkill can be run remotely, too.Just beware I think that will kill any other ruby processes also running too. If you need to shutdown the exact ruby instance that is running Webrick, you can get the process id from the webbrick console output (it''s right before the port number). for example, if 1648 is the pid displayed in the webrick shell: taskkill /F /PID 1648 will kill just webbrick without touching any other ruby processes. Jeff www.softiesonrails.com -- Posted via http://www.ruby-forum.com/.
>> > taskkill /F /IM ruby.exe >> >> taskkill can be run remotely, too. > taskkill /F /PID 1648But, there''s now way to cleanly request WEBrick to shutdown? I am starting WEBrick from an Ant script, and I''d like to have a shutdown target in there as well, to match all my other processes. The Ant script cannot read the pid from some other console window. And I don''t want to kill the process, I want to request the web server to shutdown cleanly. I cannot do this? Sounds like something to be added. Tom -- Posted via http://www.ruby-forum.com/.
On 1/14/06, Tom Harris <tom@tharrisx.homedns.org> wrote:> > >> > taskkill /F /IM ruby.exe > >> > >> taskkill can be run remotely, too. > > taskkill /F /PID 1648 > > But, there''s now way to cleanly request WEBrick to shutdown? > > I am starting WEBrick from an Ant script, and I''d like to have a > shutdown target in there as well, to match all my other processes. The > Ant script cannot read the pid from some other console window. And I > don''t want to kill the process, I want to request the web server to > shutdown cleanly. I cannot do this? Sounds like something to be added.When ant starts a process, it can''t get the pid of the started process?
Tom Harris wrote:> Is there any way to request WEBrick to shutdown besides hitting CTRL-C > at the console? > > I''m looking for, perhaps, a script/shutdown command, or perhaps a > special URL that will request WEBrick to die. > > It can be a command run in a different shell, or, as I said, a special > URL. > > Anyone?Common problem, so I have wrote a script that autogenerates basic WEBrick server code, and always include a magic URL to shutdown the server. s = HTTPServer.new( :Port => some_port_var # ... app-specific stuff s.mount_proc(''/quit'') { |req, resp| s.shutdown; exit; } Season to taste. James Britt -- http://www.ruby-doc.org - Ruby Help & Documentation http://www.artima.com/rubycs/ - The Journal By & For Rubyists http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys http://www.30secondrule.com - Building Better Tools
James Britt wrote:> Common problem, so I have wrote a script that autogenerates basic > WEBrick server code, and always include a magic URL to shutdown the > server. > > > s = HTTPServer.new( :Port => some_port_var > > # ... app-specific stuff > > s.mount_proc(''/quit'') { |req, resp| s.shutdown; exit; } > > > Season to taste.Where do I put this, in my routes.rb? Doesn''t look like this would work. WEBrick is not part of my project, and I''d really like to require users to use the one-click installer, install gem, and rails themselves. I don''t think I want to have to support a custom version of WEBrick as well as my own code, and what happens when a new version of Rails comes out? Tom -- Posted via http://www.ruby-forum.com/.
Tom Harris wrote:> James Britt wrote: > >>Common problem, so I have wrote a script that autogenerates basic >>WEBrick server code, and always include a magic URL to shutdown the >>server. >> >> >> s = HTTPServer.new( :Port => some_port_var >> >> # ... app-specific stuff >> >> s.mount_proc(''/quit'') { |req, resp| s.shutdown; exit; } >> >> >>Season to taste. > > > Where do I put this, in my routes.rb? Doesn''t look like this would work.It goes into the code that actually creates and runs the instance of a WEBrick server: webrick_server.rb The code simply associates a URL with a proc. James
James Britt wrote:> Tom Harris wrote: >>> >>> s.mount_proc(''/quit'') { |req, resp| s.shutdown; exit; } >>> >>> >>>Season to taste. >> >> >> Where do I put this, in my routes.rb? Doesn''t look like this would work. > > It goes into the code that actually creates and runs the instance of a > WEBrick server: webrick_server.rb > > The code simply associates a URL with a proc. > > > JamesThis is a change to the existing code. I guess I''m asking for either of the following: 1. Is there an existing way to do this that already in the code? 2. Can someone who has committer-rights add something like this to the WEBrick code? As I said, I don''t want to have to support my own version of WEBrick. I just need to be able to shutdown the specific WEBrick my Ant script started, either locally or remotely, in a platform-agnostic way. For something like Rails to be taken seriously in business situations, it has to be more managable, and that being able to remotely control the service on any platform. Relying on *nix commands is fine for hackers, but unfortunately, most businesses still run only Windows. At my company, we''ve been pushing for our product to be supported on Solaris or Linux for quite some time, but the response is always that the change is not cost-effective, since very few customers are actually interested in running our products on anything but Windows. They have the knowledge in-house to deal with it, they are comfortable. Anyway, </rant> Tom -- Posted via http://www.ruby-forum.com/.
2006/1/15, Tom Harris <tom@tharrisx.homedns.org>:> > As I said, I don''t want to have to support my own version of WEBrick. I > just need to be able to shutdown the specific WEBrick my Ant script > started, either locally or remotely, in a platform-agnostic way. >As James says, if you have an instance of HTTPServer, you can shut it down with s.shutdown.> This is a change to the existing code.Yes, but it is a change to existing Rails code, rather than a change to existing WEBrick code, so you won''t have to support your own version of WEBrick. Douglas
Tom Harris wrote:> ... > For something like Rails to be taken seriously in business situations, > it has to be more managable, and that being able to remotely control the > service on any platform. Relying on *nix commands is fine for hackers, > but unfortunately, most businesses still run only Windows. At my > company, we''ve been pushing for our product to be supported on Solaris > or Linux for quite some time, but the response is always that the change > is not cost-effective, since very few customers are actually interested > in running our products on anything but Windows. They have the knowledge > in-house to deal with it, they are comfortable. Anyway, </rant> >I find Rails far more manageable than the various J2EE apps I''ve worked with precisely because I *can* go and easily mod *any* code I please. It''s Ruby, not Java byte-code. I''m not at the mercy of some one-size-fits-all config or management tool that addresses every possible option expect those I actually care about. Installing a custom webrick_server.rb file is not a complicated task, and gives you complete, portable control. James Britt -- http://www.ruby-doc.org - Ruby Help & Documentation http://www.artima.com/rubycs/ - The Journal By & For Rubyists http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys http://www.30secondrule.com - Building Better Tools
Douglas Livingstone wrote:> 2006/1/15, Tom Harris <tom@tharrisx.homedns.org>: >> >> As I said, I don''t want to have to support my own version of WEBrick. I >> just need to be able to shutdown the specific WEBrick my Ant script >> started, either locally or remotely, in a platform-agnostic way. >> > > As James says, if you have an instance of HTTPServer, you can shut it > down with s.shutdown. > >> This is a change to the existing code. > > Yes, but it is a change to existing Rails code, rather than a change > to existing WEBrick code, so you won''t have to support your own > version of WEBrick. > > DouglasSo, I made a copy of the webrick_server.rb file in the following folder in my app: lib\ruby\gems\1.8\gems\rails-1.0.0\lib I added the statement inbetween, as such: server = WEBrick::HTTPServer.new(params) server.mount_proc(''/quit'') { |req, resp| server.shutdown; exit; } server.mount(''/'', DispatchServlet, options) I then run WEBrick, and try to browse to the /quit URL and get: Routing Error Recognition failed for "/quit" It looks like my overriding copy of the webrick_server.rb file isn''t being used. I don''t want to have to include all of rails in my app. I would rather require that users of this download ruby and install rails themselves. What am I doing wrong here? And how do others package and deploy things like this? Tom -- Posted via http://www.ruby-forum.com/.
On 1/16/06, Tom Harris <tom@tharrisx.homedns.org> wrote:> Douglas Livingstone wrote: > > 2006/1/15, Tom Harris <tom@tharrisx.homedns.org>: > >> > >> As I said, I don''t want to have to support my own version of WEBrick. I > >> just need to be able to shutdown the specific WEBrick my Ant script > >> started, either locally or remotely, in a platform-agnostic way. > >> > > > > As James says, if you have an instance of HTTPServer, you can shut it > > down with s.shutdown. > > > >> This is a change to the existing code. > > > > Yes, but it is a change to existing Rails code, rather than a change > > to existing WEBrick code, so you won''t have to support your own > > version of WEBrick. > > > > Douglas > > So, I made a copy of the webrick_server.rb file in the following folder > in my app: > > lib\ruby\gems\1.8\gems\rails-1.0.0\lib > > I added the statement inbetween, as such: > > server = WEBrick::HTTPServer.new(params) > server.mount_proc(''/quit'') { |req, resp| server.shutdown; exit; } > server.mount(''/'', DispatchServlet, options) > > I then run WEBrick, and try to browse to the /quit URL and get: > > Routing Error > > Recognition failed for "/quit" > > It looks like my overriding copy of the webrick_server.rb file isn''t > being used. I don''t want to have to include all of rails in my app. I > would rather require that users of this download ruby and install rails > themselves.Just curious, why don''t you want to include Rails in the vendor directory of your application? That way, you can be sure that the version of Rails that the customer is using is the one that''s sure to work with your application.> What am I doing wrong here? And how do others package and deploy things > like this?
> Just curious, why don''t you want to include Rails in the vendor > directory of your application? That way, you can be sure that the > version of Rails that the customer is using is the one that''s sure to > work with your application.This is an open-source project, for which I''m developing a rails web config. I don''t want to include ruby and rails in the project, because I want the user to install ruby on their own, if they want to use the web config. And, when rails gets fixes, I want the user to be responsible for getting the update, not me. So, any idea how to get my copy of this file to be used, short of being forced include the entirity of rails into my project? Tom -- Posted via http://www.ruby-forum.com/.
On 1/16/06, Tom Harris <tom@tharrisx.homedns.org> wrote:> > Just curious, why don''t you want to include Rails in the vendor > > directory of your application? That way, you can be sure that the > > version of Rails that the customer is using is the one that''s sure to > > work with your application. > > This is an open-source project, for which I''m developing a rails web > config. I don''t want to include ruby and rails in the project, because I > want the user to install ruby on their own, if they want to use the web > config. And, when rails gets fixes, I want the user to be responsible > for getting the update, not me.What if Rails gets fixes that break your application? Or a user downloads Rails 1.1 (or Rails 0.13.4)?> So, any idea how to get my copy of this file to be used, short of being > forced include the entirity of rails into my project?I don''t know off-hand, but I''m sure the solution won''t be too difficult.
Joe Van Dyk wrote:> On 1/16/06, Tom Harris <tom@tharrisx.homedns.org> wrote: >> > Just curious, why don''t you want to include Rails in the vendor >> > directory of your application? That way, you can be sure that the >> > version of Rails that the customer is using is the one that''s sure to >> > work with your application. >> >> This is an open-source project, for which I''m developing a rails web >> config. I don''t want to include ruby and rails in the project, because I >> want the user to install ruby on their own, if they want to use the web >> config. And, when rails gets fixes, I want the user to be responsible >> for getting the update, not me. > > What if Rails gets fixes that break your application? Or a user > downloads Rails 1.1 (or Rails 0.13.4)? > >> So, any idea how to get my copy of this file to be used, short of being >> forced include the entirity of rails into my project? > > I don''t know off-hand, but I''m sure the solution won''t be too difficult.I put in a ticket for script/server stop and script/server restart to be added. -- Posted via http://www.ruby-forum.com/.