Skip to content

Commit

Permalink
swap unicorn out for puma
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hahn authored and Greg Lazarev committed Jul 31, 2015
1 parent e021fa1 commit 93d5644
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .env
@@ -1,5 +1,7 @@
# Don't modify this file. Create `.env.local` and put your overrides in there.
CHANGED_FILES_THRESHOLD=300
DB_POOL=5
DB_REAPING_FREQUENCY=10
ENABLE_HTTPS=no
EXEMPT_ORGS=organisation_name,user_name
GITHUB_CLIENT_ID=github_client_id
Expand All @@ -8,6 +10,8 @@ HOST=your-initials-hound.ngrok.com
HOUND_GITHUB_TOKEN=your_github_token
HOUND_GITHUB_USERNAME=your_github_username
MAX_COMMENTS=10
MAX_THREADS=5
RACK_TIMEOUT=20
REDIS_URL=redis://localhost:6379
RESQUE_ADMIN_PASSWORD=password
RESQUE_JOB_TIMEOUT=120
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -24,6 +24,7 @@ gem "octokit", github: "octokit/octokit.rb"
gem "omniauth-github"
gem "paranoia", "~> 2.0"
gem "pg"
gem "puma"
gem "rails", "4.2.3"
gem "resque", "~> 1.25.0"
gem "resque-scheduler"
Expand All @@ -33,9 +34,9 @@ gem "sass-rails"
gem "split", require: "split/dashboard"
gem "stripe"
gem "uglifier", ">= 1.0.3"
gem "unicorn"

group :staging, :production do
gem "rack-timeout"
gem "rails_12factor"
gem "sentry-raven"
end
Expand Down
14 changes: 7 additions & 7 deletions Gemfile.lock
Expand Up @@ -138,7 +138,6 @@ GEM
rake
json (1.8.3)
jwt (1.0.0)
kgio (2.9.2)
launchy (2.4.2)
addressable (~> 2.3)
loofah (2.0.2)
Expand Down Expand Up @@ -188,11 +187,13 @@ GEM
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
powerpack (0.1.0)
puma (2.12.2)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rack-timeout (0.2.4)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
Expand Down Expand Up @@ -223,7 +224,6 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.4.2)
redis (3.2.1)
redis-namespace (1.5.2)
Expand Down Expand Up @@ -317,10 +317,6 @@ GEM
uglifier (2.5.3)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
uuidtools (2.1.5)
vegas (0.1.11)
rack (>= 1.0.0)
Expand Down Expand Up @@ -367,6 +363,8 @@ DEPENDENCIES
paranoia (~> 2.0)
pg
poltergeist
puma
rack-timeout
rails (= 4.2.3)
rails_12factor
resque (~> 1.25.0)
Expand All @@ -380,5 +378,7 @@ DEPENDENCIES
split
stripe
uglifier (>= 1.0.3)
unicorn
webmock

BUNDLED WITH
1.10.6
2 changes: 1 addition & 1 deletion Procfile
@@ -1,4 +1,4 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
web: bundle exec puma -C config/puma.rb
resque_high: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=8 QUEUE=high,medium bundle exec rake resque:work
resque_medium: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=8 QUEUE=medium bundle exec rake resque:work
resque_low: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=8 QUEUE=low,medium bundle exec rake resque:work
Expand Down
7 changes: 6 additions & 1 deletion config/database.yml
Expand Up @@ -2,8 +2,13 @@ development: &default
adapter: postgresql
encoding: unicode
database: hound_development
pool: 5
pool: <%= ENV.fetch("DB_POOL", 5) %>
reaping_frequency: <%= ENV.fetch("DB_REAPING_FREQUENCY", 10) %>

test:
<<: *default
database: hound_test

production:
pool: <%= [ENV.fetch("MAX_THREADS", 5), ENV.fetch("DB_POOL", 5)].max %>
url: <%= ENV.fetch("DATABASE_URL") %>
5 changes: 2 additions & 3 deletions config/environments/production.rb
Expand Up @@ -53,9 +53,6 @@
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { :host => 'houndci.com' }

# Enable threaded mode
# config.threadsafe!

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
Expand All @@ -67,3 +64,5 @@
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
end

Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 20).to_i
17 changes: 17 additions & 0 deletions config/puma.rb
@@ -0,0 +1,17 @@
workers Integer(ENV.fetch("WEB_CONCURRENCY", 3))
threads_count = Integer(ENV.fetch("MAX_THREADS", 5))
threads(threads_count, threads_count)

preload_app!

port ENV.fetch("PORT", 3000)
environment ENV.fetch("RACK_ENV", "development")

on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection

# Reconnect resque's redis after worker boots
Resque.redis = ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379")
end
22 changes: 0 additions & 22 deletions config/unicorn.rb

This file was deleted.

9 changes: 4 additions & 5 deletions spec/features/repo_list_spec.rb
Expand Up @@ -2,6 +2,7 @@

feature "Repo list", js: true do
let(:username) { ENV.fetch("HOUND_GITHUB_USERNAME") }
let(:token) { ENV.fetch("HOUND_GITHUB_TOKEN") }

scenario "user views landing page" do
user = create(:user)
Expand All @@ -16,6 +17,8 @@

scenario "user sees onboarding" do
user = create(:user)

stub_repos_requests(token)
sign_in_as(user)

visit repos_path
Expand Down Expand Up @@ -58,7 +61,6 @@
end

scenario "user syncs repos" do
token = "usergithubtoken"
user = create(:user)
repo = create(:repo, full_github_name: "user1/test-repo")
user.repos << repo
Expand All @@ -78,13 +80,13 @@
scenario "user signs up" do
user = create(:user)

stub_repos_requests(token)
sign_in_as(user)

expect(page).to have_content I18n.t("syncing_repos")
end

scenario "user activates repo" do
token = "usergithubtoken"
user = create(:user)
repo = create(:repo, private: false)
repo.users << user
Expand Down Expand Up @@ -113,7 +115,6 @@
repo.users << user
hook_url = "http://#{ENV["HOST"]}/builds"
team_id = 4567 # from fixture
token = "usergithubtoken"
stub_repo_with_org_request(repo.full_github_name, token)
stub_hook_creation_request(repo.full_github_name, hook_url, token)
stub_repo_teams_request(repo.full_github_name, token)
Expand All @@ -135,7 +136,6 @@
end

scenario "user deactivates repo" do
token = "usergithubtoken"
user = create(:user)
repo = create(:repo, :active)
repo.users << user
Expand All @@ -157,7 +157,6 @@
end

scenario "user deactivates private repo without subscription" do
token = "usergithubtoken"
user = create(:user)
repo = create(:repo, :active, private: true)
repo.users << user
Expand Down

0 comments on commit 93d5644

Please sign in to comment.