Demonstrate that queue time is not included in Unicorn's timeout
$ ruby unicorn_timeout_test.rb
starting unicorn {:worker_processes=>2, :timeout=>3}
[client] concurrently requesting /sleep/6, /sleep/4, /sleep/2, /sleep/0
Demonstrate that queue time is not included in Unicorn's timeout
$ ruby unicorn_timeout_test.rb
starting unicorn {:worker_processes=>2, :timeout=>3}
[client] concurrently requesting /sleep/6, /sleep/4, /sleep/2, /sleep/0
namespace :unicorn do | |
## | |
# Tasks | |
desc "Start unicorn" | |
task(:start) { | |
config = rails_root + "config/unicorn.rb" | |
sh "bundle exec unicorn --daemonize --config-file #{config}" | |
} |
I hereby claim:
To claim this, I am signing this object:
mode = ENV["SPEC"] || "full" | |
require_relative "spec_helper_#{mode}" |
class RackHeaderRenamer | |
# mapping example, sets/overwrites second header with first: | |
# {"X-Varnish-Proto" => "X-Forwarded-Proto"} | |
def initialize(app, mapping) | |
@app = app | |
@mapping = mapping | |
end | |
def call(env) |
require "bcrypt" | |
module GoTipping | |
class UserAuthenticator | |
def initialize(organisation, username, finder) | |
@organisation = organisation | |
@username = username | |
@finder = finder | |
end |
name = ->(i){ "method_#{i}" } | |
methods = 10.times.map do |i| | |
define_method(name[i]) do | |
if i == 0 | |
raise "Top level error from #{name[i]}" | |
else | |
begin | |
send name[i - 1] | |
rescue | |
raise "Error from rescue in #{name[i]}" |
#!/usr/bin/env zsh | |
# Migrate data between Heroku Postgres databases via pgbackups. | |
# This involves downtime via `heroku maintenance:on`. | |
# | |
# To migrate example-app to HEROKU_POSTGRESQL_COLOR: | |
# heroku-postgres-migrate.sh <example-app> <HEROKU_POSTGRESQL_COLOR> | |
# | |
# To exit maintenance mode (in case something dies half-way): | |
# heroku-postgres-migrate.sh --wake |
# Whether a method called on two objects gives two results that are | |
# equal when compared as strings. | |
def same_to_s?(a, b, method) | |
a.send(method).to_s == b.send(method).to_s rescue true | |
end | |
Result = Struct.new(:method, :class_name, :a, :b) do | |
def to_s | |
"Time#%-10s %-10s '%s' vs '%s'" % [method, class_name, a, b] | |
end |