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.