Created
March 18, 2013 14:22
-
-
Save netinlet/5187479 to your computer and use it in GitHub Desktop.
http timeout when calling into a unicorn process
This file contains hidden or 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
#==== Gemfile ==== | |
source :rubygems | |
gem 'sinatra', :require => 'sinatra/base' | |
gem 'rest-client' | |
gem 'unicorn' | |
gem 'puma' | |
#==== config.ru ==== | |
require "rubygems" | |
require "bundler/setup" | |
require "sinatra" | |
require File.expand_path 'app' | |
run UnicornTimeout | |
#==== app.rb ==== | |
require 'rest_client' | |
class UnicornTimeout < Sinatra::Base | |
get "/dashboard" do | |
content_type "text/plain" | |
begin | |
result = RestClient::Request.execute(:method => :get, :url => "http://localhost:9292/status", :timeout => 10, :open_timeout => 10) | |
"Dashboard received: #{result}" | |
rescue StandardError => e | |
e.message | |
end | |
end | |
get "/status" do | |
content_type "text/plain" | |
"Status: 'ok'" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment