Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

migrate to puma

  • Loading branch information...
commit 100b94a9498b5002152394083d5739b4c16c67d9 1 parent 84d575d
@ck3g authored
View
4 Gemfile
@@ -29,7 +29,6 @@ group :development do
gem "capistrano", require: false
gem 'capistrano-recipes', require: false
gem 'capistrano_colors', require: false
- gem 'capistrano-unicorn', '~> 0.1.6', require: false
gem "erb2haml"
gem "rails_best_practices"
gem "thin"
@@ -59,7 +58,6 @@ end
group :production do
gem "exception_notification"
- gem "unicorn", "~> 4.6.0"
+ gem "puma"
end
-gem "puma"
View
22 Gemfile.lock
@@ -47,8 +47,6 @@ GEM
capistrano-recipes (0.8.0)
capistrano (>= 2.5.9)
capistrano-ext (>= 1.2.1)
- capistrano-unicorn (0.1.7)
- capistrano
capistrano_colors (0.5.5)
capybara (1.1.3)
mime-types (>= 1.16)
@@ -59,7 +57,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
- code_analyzer (0.3.0)
+ code_analyzer (0.3.1)
sexp_processor
coderay (1.0.8)
coffee-rails (3.2.2)
@@ -123,7 +121,6 @@ GEM
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
- kgio (2.8.0)
launchy (2.1.2)
addressable (~> 2.3)
libnotify (0.5.9)
@@ -138,7 +135,7 @@ GEM
actionpack
method_source (0.8.1)
mime-types (1.21)
- multi_json (1.7.1)
+ multi_json (1.7.2)
multipart-post (1.1.5)
mysql2 (0.3.11)
net-scp (1.0.4)
@@ -152,7 +149,6 @@ GEM
nokogiri (1.5.5)
orm_adapter (0.4.0)
polyglot (0.3.3)
- progressbar (0.11.0)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
@@ -177,14 +173,14 @@ GEM
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
- rails_best_practices (1.12.0)
+ rails_best_practices (1.13.4)
activesupport
awesome_print
code_analyzer
colored
erubis
i18n
- progressbar
+ ruby-progressbar
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
@@ -192,7 +188,6 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
- raindrops (0.10.0)
rake (10.0.3)
rb-fsevent (0.9.2)
rb-inotify (0.8.8)
@@ -212,6 +207,7 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
+ ruby-progressbar (1.0.2)
ruby_parser (3.0.1)
sexp_processor (~> 4.1)
rubyzip (0.9.9)
@@ -225,7 +221,7 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- sexp_processor (4.1.2)
+ sexp_processor (4.2.0)
shoulda (3.3.2)
shoulda-context (~> 1.0.1)
shoulda-matchers (~> 1.4.1)
@@ -275,10 +271,6 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
- unicorn (4.6.2)
- kgio (~> 2.6)
- rack
- raindrops (~> 0.7)
warden (1.2.1)
rack (>= 1.0)
websocket (1.0.1)
@@ -294,7 +286,6 @@ DEPENDENCIES
anjlab-bootstrap-rails (> 2.2)
capistrano
capistrano-recipes
- capistrano-unicorn (~> 0.1.6)
capistrano_colors
capybara (~> 1.1.2)
coffee-rails (~> 3.2.2)
@@ -332,5 +323,4 @@ DEPENDENCIES
therubyracer
thin
uglifier (>= 1.0.3)
- unicorn (~> 4.6.0)
zeus
View
30 config/deploy.rb
@@ -7,8 +7,8 @@
set :branch, "master"
set :shared_host, "194.165.39.126"
set :domain, shared_host
-set :unicorn_env, "production"
set :rails_env, "production"
+set :puma_env, "production"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
@@ -61,6 +61,32 @@
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
+ puma_env = fetch(:rack_env, fetch(:rails_env, 'production'))
+ 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 'bundler/capistrano'
-require "capistrano-unicorn"
View
2  config/puma.rb
@@ -6,7 +6,7 @@
app_path = "#{deploy_to}/current"
shared_path = "#{deploy_to}/shared"
-bind "unix://#{shared_path}/sockets/unicorn.sock"
+bind "unix://#{shared_path}/sockets/puma.sock"
pidfile "#{app_path}/tmp/puma/pid"
state_path "#{app_path}/tmp/puma/state"
View
43 config/unicorn/production.rb
@@ -1,43 +0,0 @@
-# Set your full path to application.
-deploy_to = "/home/kalastiuz/apps/homebugh"
-app_path = "#{deploy_to}/current"
-shared_path = "#{deploy_to}/shared"
-
-# Set unicorn options
-worker_processes 8
-preload_app true
-timeout 120
-listen "#{shared_path}/sockets/unicorn.sock", :backlog => 2048
-
-# Spawn unicorn master worker for user apps (group: apps)
-user 'kalastiuz', 'kalastiuz'
-
-# Fill path to your app
-working_directory app_path
-
-# Should be 'production' by default, otherwise use other env
-rails_env = ENV['RAILS_ENV'] || 'production'
-
-# Log everything to one file
-stderr_path "#{shared_path}/log/unicorn.stderr.log"
-stdout_path "#{shared_path}/log/unicorn.stdout.log"
-
-# Set master PID location
-pid "#{app_path}/tmp/pids/unicorn.pid"
-
-before_fork do |server, worker|
- ActiveRecord::Base.connection.disconnect!
-
- old_pid = "#{server.config[:pid]}.oldbin"
- if File.exists?(old_pid) && server.pid != old_pid
- begin
- Process.kill("QUIT", File.read(old_pid).to_i)
- rescue Errno::ENOENT, Errno::ESRCH
- # someone else did our job for us
- end
- end
-end
-
-after_fork do |server, worker|
- ActiveRecord::Base.establish_connection
-end
Please sign in to comment.
Something went wrong with that request. Please try again.