bala Paranj wrote:
> Enjoy this little script to restart webrick:
I do that like this:
def croakServer(server, response)
response.status = 200
response[''Content-Type''] = "text/html"
response.body = ''<html><head><title>Shutting
Down</title></head>
<body>Shutting down
MiniWikiRuby...</body></html>''
server.shutdown()
end
def bounceServer(server, response)
response.status = 200
response[''Content-Type''] = "text/html"
response.body =
''<html><head><title>Bouncing</title></head>
<body>Bouncing
MiniWikiRuby...</body></html>''
server.shutdown()
launch("ruby miniWiki.rb " + ARGV.join('' ''))
end
if 80 != port then
server.mount_proc ''/croak'' do |request, response|
croakServer(server, response)
end
server.mount_proc ''/bounce'' do |request, response|
bounceServer(server, response)
end
end
If you mount Webrick on a non-public port, it exposes two "actions",
croak
and bounce. They croak and bounce, respectively.
From a script, you can simply croak your server with
wget http://localhost:8080/croak
My (non-Rails) tests bounce a lite server when they start, using Net::HTTP
for the wget role.
--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---