Enjoy this little script to restart webrick:
#!/bin/sh
pid=$(ps -o pid,command | grep ‘<ruby script/server>’ | awk ‘{print
$1}’)
kill -9 $pid
ruby script/server
Run on prompt by entering: sh scriptname.sh
Enjoy this little script to restart webrick:
#!/bin/sh
pid=$(ps -o pid,command | grep ‘<ruby script/server>’ | awk ‘{print
$1}’)
kill -9 $pid
ruby script/server
Run on prompt by entering: sh scriptname.sh
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…’
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
Redirecting... ← NOT a blog!!!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs