Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
migrate from unicorn to puma
  • Loading branch information
ck3g committed Apr 6, 2013
1 parent b717d7d commit e5aa1f6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 57 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Expand Up @@ -49,7 +49,6 @@ group :development do
gem "capistrano", "~> 2.14.2", :require => false gem "capistrano", "~> 2.14.2", :require => false
gem 'capistrano-recipes', :require => false gem 'capistrano-recipes', :require => false
gem 'capistrano_colors', :require => false gem 'capistrano_colors', :require => false
gem 'capistrano-unicorn', '~> 0.1.6', require: false
gem "rails_best_practices" gem "rails_best_practices"
gem "thin" gem "thin"
gem "zeus" gem "zeus"
Expand All @@ -70,4 +69,6 @@ group :test do
gem "email_spec", "~> 1.2.1" gem "email_spec", "~> 1.2.1"
end end


gem "unicorn", "~> 4.6.0", group: [:development, :production] group :production do
gem "puma"
end
13 changes: 3 additions & 10 deletions Gemfile.lock
Expand Up @@ -59,8 +59,6 @@ GEM
capistrano-recipes (0.8.0) capistrano-recipes (0.8.0)
capistrano (>= 2.5.9) capistrano (>= 2.5.9)
capistrano-ext (>= 1.2.1) capistrano-ext (>= 1.2.1)
capistrano-unicorn (0.1.7)
capistrano
capistrano_colors (0.5.5) capistrano_colors (0.5.5)
capybara (1.1.4) capybara (1.1.4)
mime-types (>= 1.16) mime-types (>= 1.16)
Expand Down Expand Up @@ -135,7 +133,6 @@ GEM
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
railties (>= 3.0.0) railties (>= 3.0.0)
kgio (2.8.0)
launchy (2.1.2) launchy (2.1.2)
addressable (~> 2.3) addressable (~> 2.3)
libv8 (3.11.8.13) libv8 (3.11.8.13)
Expand Down Expand Up @@ -177,6 +174,8 @@ GEM
slop (~> 3.3.1) slop (~> 3.3.1)
pry-rails (0.2.2) pry-rails (0.2.2)
pry (>= 0.9.10) pry (>= 0.9.10)
puma (1.6.3)
rack (~> 1.2)
rack (1.4.5) rack (1.4.5)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
Expand Down Expand Up @@ -207,7 +206,6 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
raindrops (0.10.0)
rake (10.0.3) rake (10.0.3)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
Expand Down Expand Up @@ -293,10 +291,6 @@ GEM
uglifier (1.3.0) uglifier (1.3.0)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2) multi_json (~> 1.0, >= 1.0.2)
unicorn (4.6.2)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
warden (1.2.1) warden (1.2.1)
rack (>= 1.0) rack (>= 1.0)
websocket (1.0.6) websocket (1.0.6)
Expand All @@ -318,7 +312,6 @@ DEPENDENCIES
cancan (~> 1.6.8) cancan (~> 1.6.8)
capistrano (~> 2.14.2) capistrano (~> 2.14.2)
capistrano-recipes capistrano-recipes
capistrano-unicorn (~> 0.1.6)
capistrano_colors capistrano_colors
capybara (~> 1.1.2) capybara (~> 1.1.2)
carrierwave (~> 0.8.0) carrierwave (~> 0.8.0)
Expand All @@ -340,6 +333,7 @@ DEPENDENCIES
mini_magick (~> 3.5.0) mini_magick (~> 3.5.0)
pg pg
pry-rails pry-rails
puma
rails (~> 3.2.13) rails (~> 3.2.13)
rails_best_practices rails_best_practices
rspec-rails (~> 2.11.0) rspec-rails (~> 2.11.0)
Expand All @@ -353,5 +347,4 @@ DEPENDENCIES
tiny_tds (~> 0.5.1) tiny_tds (~> 0.5.1)
twitter_cldr (~> 2.2.0) twitter_cldr (~> 2.2.0)
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
unicorn (~> 4.6.0)
zeus zeus
29 changes: 27 additions & 2 deletions config/deploy.rb
Expand Up @@ -10,7 +10,7 @@
set :application, "sc2_news" set :application, "sc2_news"
set :deploy_to, "/home/#{user}/apps/#{application}/" set :deploy_to, "/home/#{user}/apps/#{application}/"
set :branch, "master" set :branch, "master"
set :unicorn_env, "production" set :puma_env, "production"
set :rails_env, "production" set :rails_env, "production"


#default_run_options[:shell] = '/bin/bash' #default_run_options[:shell] = '/bin/bash'
Expand Down Expand Up @@ -74,7 +74,32 @@
end end
end end


after 'deploy:stop', 'puma:stop'
after 'deploy:start', 'puma:start'
after 'deploy:restart', 'puma:restart'

_cset(:puma_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec puma" }
_cset(:pumactl_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec pumactl" }
_cset(:puma_state) { "#{shared_path}/sockets/puma.state" }
_cset(:puma_role) { :app }

namespace :puma do
desc 'Start puma'
task :start, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
run "cd #{current_path} && #{fetch(:puma_cmd)} -t 4:4 -q -e #{puma_env} -b 'unix://#{shared_path}/sockets/puma.sock' -S #{fetch(:puma_state)} --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{puma_env}.log 2>&1 &", :pty => false
end

desc 'Stop puma'
task :stop, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
run "cd #{current_path} && #{fetch(:pumactl_cmd)} -S #{fetch(:puma_state)} stop"
end

desc 'Restart puma'
task :restart, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
run "cd #{current_path} && #{fetch(:pumactl_cmd)} -S #{fetch(:puma_state)} restart"
end
end

require 'capistrano_colors' require 'capistrano_colors'
require 'bundler/capistrano' require 'bundler/capistrano'
require "capistrano-unicorn"


13 changes: 13 additions & 0 deletions config/puma.rb
@@ -0,0 +1,13 @@
rails_env = ENV["RAILS_ENV"] || "development"

threads 4,4

deploy_to = "/home/kalastiuz/apps/sc2_news"
app_path = "#{deploy_to}/current"
shared_path = "#{deploy_to}/shared"

bind "unix://#{shared_path}/sockets/puma.sock"
pidfile "#{app_path}/tmp/puma/pid"
state_path "#{app_path}/tmp/puma/state"

activate_control_app
43 changes: 0 additions & 43 deletions config/unicorn/production.rb

This file was deleted.

0 comments on commit e5aa1f6

Please sign in to comment.