Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created November 7, 2012 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechamogera/4028794 to your computer and use it in GitHub Desktop.
Save mechamogera/4028794 to your computer and use it in GitHub Desktop.
ELBのOutOfService時のセッション確認用
require 'rubygems'
require 'rest-client'
RestClient.proxy = ENV['http_proxy']
while true
begin
res = RestClient.get( 'http://[ELBのドメイン名]/test' )
puts res.body
rescue RestClient::Exception => e
p #{e.response.code} #{e.message}"
rescue => e
p e.message
end
end
#! /bin/env ruby
require 'webrick'
require 'yaml'
require "socket"
logger = WEBrick::Log::new(STDERR, WEBrick::Log::DEBUG)
server = WEBrick::HTTPServer.new(
:Port => 8080,
:BindAddress => IPSocket::getaddress(Socket::gethostname),
:Logger => logger
)
server.mount_proc('/test') do |req, res|
logger.debug("===== recieved a =====")
sleep 50
res.body = "a"
res['Content-Type'] = 'text/plain'
end
server.mount_proc('/ping') do |req, res|
res.status = WEBrick::HTTPStatus::RC_SERVICE_UNAVAILABLE unless YAML.load_file("server.yml")["healthok"]
end
trap("INT") { server.shutdown }
server.start
healthok : true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment