Skip to content

Commit c2f8731

Browse files
committed
Use Puma.
1 parent 3958301 commit c2f8731

File tree

5 files changed

+17
-72
lines changed

5 files changed

+17
-72
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ group :development, :test do
110110
end
111111

112112
group :production do
113-
gem 'unicorn'
113+
gem "puma", "2.6.0"
114114
gem 'newrelic_rpm'
115115
end

Gemfile.lock

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ GEM
195195
json (1.8.0)
196196
jwt (0.1.8)
197197
multi_json (>= 1.5)
198-
kgio (2.8.1)
199198
launchy (2.1.0)
200199
addressable (~> 2.2.6)
201200
letter_opener (0.0.2)
@@ -262,6 +261,8 @@ GEM
262261
actionmailer
263262
postmark (>= 0.9.0)
264263
rake
264+
puma (2.6.0)
265+
rack (>= 1.1, < 2.0)
265266
quiet_assets (1.0.2)
266267
railties (>= 3.1, < 5.0)
267268
rack (1.5.2)
@@ -286,7 +287,6 @@ GEM
286287
activesupport (= 4.0.0)
287288
rake (>= 0.8.7)
288289
thor (>= 0.18.1, < 2.0)
289-
raindrops (0.12.0)
290290
rake (10.1.0)
291291
redcarpet (3.0.0)
292292
redis (3.0.2)
@@ -372,10 +372,6 @@ GEM
372372
uglifier (2.1.1)
373373
execjs (>= 0.3.0)
374374
multi_json (~> 1.0, >= 1.0.2)
375-
unicorn (4.6.3)
376-
kgio (~> 2.6)
377-
rack
378-
raindrops (~> 0.7)
379375
warden (1.2.3)
380376
rack (>= 1.0)
381377
websocket (1.0.4)
@@ -429,6 +425,7 @@ DEPENDENCIES
429425
omniauth (~> 1.0.1)
430426
omniauth-github (~> 1.1.0)
431427
postmark-rails (= 0.4.1)
428+
puma (= 2.6.0)
432429
quiet_assets (~> 1.0.2)
433430
rails (= 4.0.0)
434431
rails-i18n (= 0.1.8)
@@ -449,5 +446,4 @@ DEPENDENCIES
449446
thin (= 1.5.0)
450447
turbolinks (~> 1.2.0)
451448
uglifier (>= 1.3.0)
452-
unicorn
453449
will_paginate (= 3.0.4)

config/deploy.rb

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require "bundler/capistrano"
33
require "sidekiq/capistrano"
44
require "rvm/capistrano"
5+
require 'puma/capistrano'
56

67
default_run_options[:pty] = true
78

@@ -16,29 +17,13 @@
1617
set :runner, "ruby"
1718
# set :deploy_via, :remote_cache
1819
set :git_shallow_clone, 1
20+
set :puma_role, :app
21+
set :puma_config_file, "config/puma.rb"
1922

2023
role :web, "ruby-china.org" # Your HTTP server, Apache/etc
2124
role :app, "ruby-china.org" # This may be the same as your `Web` server
2225
role :db, "ruby-china.org", :primary => true # This is where Rails migrations will run
2326

24-
# unicorn.rb 路径
25-
set :unicorn_path, "#{deploy_to}/current/config/unicorn.rb"
26-
27-
namespace :deploy do
28-
task :start, :roles => :app do
29-
run "cd #{deploy_to}/current/; RAILS_ENV=production bundle exec unicorn_rails -c #{unicorn_path} -D"
30-
end
31-
32-
task :stop, :roles => :app do
33-
run "kill -QUIT `cat #{deploy_to}/current/tmp/pids/unicorn.pid`"
34-
end
35-
36-
desc "Restart Application"
37-
task :restart, :roles => :app do
38-
run "kill -USR2 `cat #{deploy_to}/current/tmp/pids/unicorn.pid`"
39-
end
40-
end
41-
4227
namespace :faye do
4328
desc "Start Faye"
4429
task :start, :roles => :app do
@@ -56,7 +41,6 @@
5641
end
5742
end
5843

59-
6044
task :init_shared_path, :roles => :web do
6145
run "mkdir -p #{deploy_to}/shared/log"
6246
run "mkdir -p #{deploy_to}/shared/pids"
@@ -65,9 +49,9 @@
6549

6650
task :link_shared_files, :roles => :web do
6751
run "ln -sf #{deploy_to}/shared/config/*.yml #{deploy_to}/current/config/"
68-
run "ln -sf #{deploy_to}/shared/config/unicorn.rb #{deploy_to}/current/config/"
6952
run "ln -sf #{deploy_to}/shared/config/initializers/secret_token.rb #{deploy_to}/current/config/initializers"
7053
run "ln -sf #{deploy_to}/shared/config/faye_thin.yml #{deploy_to}/current/faye_server/thin.yml"
54+
run "ln -sf #{shared_path}/pids #{deploy_to}/current/tmp/"
7155
end
7256

7357
task :mongoid_create_indexes, :roles => :web do
@@ -76,14 +60,11 @@
7660

7761
task :compile_assets, :roles => :web do
7862
run "cd #{deploy_to}/current/; RAILS_ENV=production bundle exec rake assets:precompile"
79-
end
80-
81-
task :sync_assets_to_cdn, :roles => :web do
8263
run "cd #{deploy_to}/current/; RAILS_ENV=production bundle exec rake assets:cdn"
8364
end
8465

8566
task :mongoid_migrate_database, :roles => :web do
8667
run "cd #{deploy_to}/current/; RAILS_ENV=production bundle exec rake db:migrate"
8768
end
8869

89-
after "deploy:finalize_update","deploy:symlink", :init_shared_path, :link_shared_files, :compile_assets, :sync_assets_to_cdn, :mongoid_migrate_database
70+
after "deploy:finalize_update","deploy:symlink", :init_shared_path, :link_shared_files, :mongoid_migrate_database , :compile_assets

config/puma.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
APP_ROOT = '/home/ruby/www/ruby-china/current'
2+
pidfile "#{APP_ROOT}/tmp/pids/puma.pid"
3+
state_path "#{APP_ROOT}/tmp/pids/puma.state"
4+
daemonize true
5+
workers 2
6+
threads 8,32
7+
preload_app!
8+

config/unicorn.rb

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)