Created
November 7, 2012 00:46
-
-
Save mechamogera/4028794 to your computer and use it in GitHub Desktop.
ELBのOutOfService時のセッション確認用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
healthok : true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment