Added puma gem

This commit is contained in:
Vokhmin Alexey V 2013-11-27 21:07:18 +04:00
parent de7b60fac2
commit 5e5f5f3f07
4 changed files with 51 additions and 8 deletions

View File

@ -39,7 +39,7 @@ gem 'rdiscount'
gem 'RedCloth' gem 'RedCloth'
gem 'wikicloth' gem 'wikicloth'
gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx] # gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', :platforms => :jruby gem 'trinidad', '~> 1.0.2', :platforms => :jruby
gem 'newrelic_rpm', '~> 3.5.5.38', :platforms => [:mri, :rbx] gem 'newrelic_rpm', '~> 3.5.5.38', :platforms => [:mri, :rbx]
gem 'whenever', '~> 0.7.3', :require => false gem 'whenever', '~> 0.7.3', :require => false
@ -89,6 +89,7 @@ group :production do
gem 'bluepill', '~> 0.0.60', :require => false gem 'bluepill', '~> 0.0.60', :require => false
# gem 'le' # gem 'le'
gem 'logglier' gem 'logglier'
gem 'puma'
end end
group :development do group :development do

View File

@ -177,7 +177,6 @@ GEM
json (1.8.0) json (1.8.0)
jwt (0.1.8) jwt (0.1.8)
multi_json (>= 1.5) multi_json (>= 1.5)
kgio (2.8.0)
libv8 (3.3.10.4) libv8 (3.3.10.4)
localeapp (0.6.14) localeapp (0.6.14)
gli gli
@ -269,6 +268,8 @@ GEM
pg (0.14.1) pg (0.14.1)
polyglot (0.3.3) polyglot (0.3.3)
posix-spawn (0.3.6) posix-spawn (0.3.6)
puma (2.6.0)
rack (>= 1.1, < 2.0)
pygments.rb (0.2.13) pygments.rb (0.2.13)
rubypython (~> 0.5.3) rubypython (~> 0.5.3)
rack (1.4.5) rack (1.4.5)
@ -303,7 +304,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.11.0)
rake (10.1.0) rake (10.1.0)
rdiscount (2.1.6) rdiscount (2.1.6)
rdoc (3.12.2) rdoc (3.12.2)
@ -424,10 +424,6 @@ GEM
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.3) multi_json (~> 1.3)
underscore-rails (1.5.1) underscore-rails (1.5.1)
unicorn (4.3.1)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
useragent (0.4.16) useragent (0.4.16)
uuid (2.3.7) uuid (2.3.7)
macaddr (~> 1.0) macaddr (~> 1.0)
@ -499,6 +495,7 @@ DEPENDENCIES
paperclip (~> 3.3.1) paperclip (~> 3.3.1)
perform_later (~> 1.3.0) perform_later (~> 1.3.0)
pg (~> 0.14.0) pg (~> 0.14.0)
puma
rack-throttle rack-throttle
rails (= 3.2.13) rails (= 3.2.13)
rails3-generators rails3-generators
@ -529,7 +526,6 @@ DEPENDENCIES
turbo-sprockets-rails3 turbo-sprockets-rails3
uglifier (~> 1.2.4) uglifier (~> 1.2.4)
underscore-rails underscore-rails
unicorn (~> 4.3.1)
whenever (~> 0.7.3) whenever (~> 0.7.3)
wikicloth wikicloth
will_paginate (~> 3.0.3) will_paginate (~> 3.0.3)

19
config/puma.rb Normal file
View File

@ -0,0 +1,19 @@
environment ENV['RAILS_ENV']
threads *(ENV['PUMA_THREADS'] || '1,5').split(',')
workers ENV['PUMA_WORKERS'] || 6
preload_app!
on_worker_boot do
if defined?(ActiveRecord::Base)
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection
end
# QC::Conn.connect
Rails.logger.info('Connected to PG')
end
# Redis.connect!
# Rails.logger.info('Connected to Redis')
end

27
lib/recipes/puma.rb Normal file
View File

@ -0,0 +1,27 @@
# -*- encoding : utf-8 -*-
Capistrano::Configuration.instance(:must_exist).load do
namespace :deploy do
# bundle exec puma -p $PORT -C config/puma.rb
set :puma_binary, "bundle exec puma"
set(:puma_pid) { "#{fetch :shared_path}/pids/unicorn.pid" }
# set :unicorn_port, 8080
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{fetch :current_path} && #{try_sudo} #{puma_binary} -b /tmp/#{fetch :application}_unicorn.sock -e #{rails_env} -C config/puma.rb -D" # -p #{unicorn_port}
end
task :stop, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} kill `cat #{puma_pid}`" rescue warn 'deploy:stop FAILED'
end
task :graceful_stop, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} kill -QUIT `cat #{puma_pid}`" rescue warn 'deploy:graceful_stop FAILED'
end
task :reload, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} kill -USR2 `cat #{puma_pid}`" rescue warn 'deploy:reload FAILED'
end
task :restart, :roles => :app, :except => { :no_release => true } do
reload
#stop
#start # blue pill will do it?
end
end
end