Last active
June 14, 2017 18:34
-
-
Save tkling/b5458b195c03a167a45d312fd66d2892 to your computer and use it in GitHub Desktop.
rack-timeout will raise errors during HTTP waits
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
# in Gemfile | |
gem 'rack-timeout', '~> 0.4' | |
# add a throwaway controller for testing | |
class WaitController < ApplicationController | |
def index | |
sleep 20 | |
render plain: 'lol we waited 20 seconds' | |
end | |
def lol | |
HTTParty.get('http://localhost:2017/waitplz') | |
render plain: 'wow that worked wtf?' | |
end | |
end | |
# in config/routes.rb | |
get 'waitplz', to: 'wait#index' | |
get 'callplz', to: 'wait#lol' | |
# start 2 copies of the app | |
# edit Passengerfile.json to start on port 2017 | |
$ sudo RAILS_ENV=production bundle exec passenger start | |
# normal dev-mode startup | |
$ bundle exec rails s | |
# then hit localhost:3000/callplz in your browser and you'll be greeted with this a exception: | |
# Rack::Timeout::RequestTimeoutException at /callplz | |
# Request ran for longer than 15000ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment