deploy.example.rb
2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Deploy Config
# =============
#
# Copy this file to config/deploy.rb and customize it as needed.
# Then run `cap errbit:setup` to set up your server and finally
# `cap deploy` whenever you would like to deploy Errbit. Refer
# to ./docs/deployment/capistrano.md for more info
# config valid only for current version of Capistrano
lock '3.3.5'
set :application, 'errbit'
set :repo_url, 'https://github.com/errbit/errbit.git'
set :branch, ENV['branch'] || 'master'
set :deploy_to, '/var/www/apps/errbit'
set :keep_releases, 5
set :pty, true
set :ssh_options, forward_agent: true
set :linked_files, fetch(:linked_files, []) + %w(
.env
config/newrelic.yml
config/unicorn.rb
)
set :linked_dirs, fetch(:linked_dirs, []) + %w(
log
tmp/cache tmp/pids tmp/sockets
vendor/bundle
)
# check out capistrano-rbenv documentation
# set :rbenv_type, :system
# set :rbenv_path, '/usr/local/rbenv'
# set :rbenv_ruby, File.read(File.expand_path('../../.ruby-version', __FILE__)).strip
# set :rbenv_roles, :all
namespace :errbit do
desc "Setup config files (first time setup)"
task :setup do
on roles(:app) do
execute "mkdir -p #{shared_path}/config"
execute "mkdir -p #{shared_path}/pids"
execute "touch #{shared_path}/.env"
{
'config/newrelic.example.yml' => 'config/newrelic.yml',
'config/unicorn.default.rb' => 'config/unicorn.rb',
}.each do |src, target|
unless test("[ -f #{shared_path}/#{target} ]")
upload! src, "#{shared_path}/#{target}"
end
end
end
end
end
namespace :db do
desc "Create and setup the mongo db"
task :setup do
on roles(:db) do
within current_path do
with rails_env: fetch(:rails_env) do
execute :rake, 'errbit:bootstrap'
end
end
end
end
end
set :unicorn_pidfile, "#{fetch(:deploy_to)}/shared/pids/unicorn.pid"
set :unicorn_pid, "`cat #{fetch(:unicorn_pidfile)}`"
namespace :unicorn do
desc 'Start unicorn'
task :start do
on roles(:app) do
within current_path do
execute "UNICORN_PID=\"#{fetch(:unicorn_pidfile)}\"", "bundle exec unicorn -D -c ./config/unicorn.rb"
end
end
end
desc 'Reload unicorn'
task :reload do
on roles(:app) do
execute :kill, "-HUP #{fetch(:unicorn_pid)}"
end
end
desc 'Stop unicorn'
task :stop do
on roles(:app) do
execute :kill, "-QUIT #{fetch(:unicorn_pid)}"
end
end
desc 'Reexecute unicorn'
task :reexec do
on roles(:app) do
execute :kill, "-USR2 #{fetch(:unicorn_pid)}"
end
end
end