Skip to content

Instantly share code, notes, and snippets.

@netinlet
Created March 18, 2013 14:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netinlet/5187479 to your computer and use it in GitHub Desktop.
Save netinlet/5187479 to your computer and use it in GitHub Desktop.
http timeout when calling into a unicorn process
#==== 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