Commit ca541c98915fd42e79af7b93c831097d9efb86a8

Authored by Vasily Gotovko
1 parent 9d2a5007
Exists in master and in 1 other branch production

Add unicorn tasks

@@ -95,7 +95,7 @@ group :test do @@ -95,7 +95,7 @@ group :test do
95 gem 'timecop' 95 gem 'timecop'
96 end 96 end
97 97
98 -group :heroku do 98 +group :heroku, :production do
99 gem 'unicorn' 99 gem 'unicorn'
100 end 100 end
101 101
config/config.example.yml
@@ -53,6 +53,8 @@ deployment: @@ -53,6 +53,8 @@ deployment:
53 repository: http://github.com/errbit/errbit.git 53 repository: http://github.com/errbit/errbit.git
54 user: deploy 54 user: deploy
55 deploy_to: /var/www/apps/errbit 55 deploy_to: /var/www/apps/errbit
  56 + # setup path to unicorn pids folder (or deploy_to/shared/pids will be used)
  57 + # pids: /var/www/apps/errbit/shared/pids
56 58
57 # GitHub OAuth configuration 59 # GitHub OAuth configuration
58 # If you want to allow authentication via GitHub, you will need to register 60 # If you want to allow authentication via GitHub, you will need to register
config/deploy.example.rb
@@ -39,6 +39,8 @@ set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't d @@ -39,6 +39,8 @@ set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't d
39 set :branch, defer { current_branch } 39 set :branch, defer { current_branch }
40 40
41 after 'deploy:update_code', 'errbit:symlink_configs' 41 after 'deploy:update_code', 'errbit:symlink_configs'
  42 +# uncomment if unicorn is running on production (do not forget to setup config)
  43 +# after 'deploy:restart', 'unicorn:stop'
42 44
43 namespace :deploy do 45 namespace :deploy do
44 task :start do ; end 46 task :start do ; end
@@ -72,3 +74,24 @@ namespace :db do @@ -72,3 +74,24 @@ namespace :db do
72 end 74 end
73 end 75 end
74 76
  77 +namespace :unicorn do
  78 + set(:unicorn_pid) do
  79 + path = config['pids'] || "#{deploy_to}/shared/pids"
  80 + "`cat #{path}/unicorn.pid`"
  81 + end
  82 +
  83 + desc 'Reload unicorn'
  84 + task :reload, :roles => :app, :except => { :no_release => true } do
  85 + run "kill -HUP #{unicorn_pid}"
  86 + end
  87 +
  88 + desc 'Stop unicorn'
  89 + task :stop, :roles => :app, :except => { :no_release => true } do
  90 + run "kill -QUIT #{unicorn_pid}"
  91 + end
  92 +
  93 + desc 'Reexecute unicorn'
  94 + task :reexec, :roles => :app, :except => { :no_release => true } do
  95 + run "kill -USR2 #{unicorn_pid}"
  96 + end
  97 +end