Commit 80d63a36c68e1189c64bacdc45541c2fcff3f752
1 parent
e3318f85
Exists in
master
and in
1 other branch
new changes deploy mode
Showing
4 changed files
with
95 additions
and
22 deletions
Show diff stats
Capfile
1 | 1 | # Load DSL and Setup Up Stages |
2 | 2 | require 'capistrano/setup' |
3 | - | |
4 | -# Includes default deployment tasks | |
5 | 3 | require 'capistrano/deploy' |
6 | 4 | |
7 | -# Includes tasks from other gems included in your Gemfile | |
8 | -# | |
9 | -# For documentation on these, see for example: | |
10 | -# | |
11 | -# https://github.com/capistrano/rvm | |
12 | -# https://github.com/capistrano/rbenv | |
13 | -# https://github.com/capistrano/chruby | |
14 | -# https://github.com/capistrano/bundler | |
15 | -# https://github.com/capistrano/rails | |
16 | -# | |
17 | -# require 'capistrano/rvm' | |
18 | -# require 'capistrano/rbenv' | |
19 | -# require 'capistrano/chruby' | |
20 | -# require 'capistrano/bundler' | |
21 | -# require 'capistrano/rails/assets' | |
22 | -# require 'capistrano/rails/migrations' | |
5 | +require 'capistrano/rails' | |
6 | +require 'capistrano/bundler' | |
7 | +require 'capistrano/rvm' | |
8 | +require 'capistrano/puma' | |
23 | 9 | |
24 | 10 | # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. |
25 | 11 | Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } | ... | ... |
config/deploy.rb
... | ... | @@ -7,6 +7,9 @@ set :user, 'deployer' |
7 | 7 | set :puma_threads, [4, 16] |
8 | 8 | set :puma_workers, 0 |
9 | 9 | |
10 | +# Default branch is :master | |
11 | +ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call | |
12 | + | |
10 | 13 | # Don't change these unless you know what you're doing |
11 | 14 | set :pty, true |
12 | 15 | set :use_sudo, false | ... | ... |
... | ... | @@ -0,0 +1,84 @@ |
1 | +# Change these | |
2 | +server '150.165.204.80', port: 22, password: 'l1br4s-l1v3', roles: [:web, :app, :db], primary: true | |
3 | + | |
4 | +set :repo_url, 'git@git.lavid.ufpb.br:vlibras-web2.git' | |
5 | +set :application, 'vlibras-web2' | |
6 | +set :user, 'deployer' | |
7 | +set :puma_threads, [4, 16] | |
8 | +set :puma_workers, 0 | |
9 | + | |
10 | +# Don't change these unless you know what you're doing | |
11 | +set :pty, true | |
12 | +set :use_sudo, false | |
13 | +set :stage, :production | |
14 | +set :deploy_via, :remote_cache | |
15 | +set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}" | |
16 | +set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" | |
17 | +set :puma_state, "#{shared_path}/tmp/pids/puma.state" | |
18 | +set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" | |
19 | +set :puma_access_log, "#{release_path}/log/puma.error.log" | |
20 | +set :puma_error_log, "#{release_path}/log/puma.access.log" | |
21 | +set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } | |
22 | +set :puma_preload_app, true | |
23 | +set :puma_worker_timeout, nil | |
24 | +set :puma_init_active_record, true # Change to false when not using ActiveRecord | |
25 | + | |
26 | +## Defaults: | |
27 | +# set :scm, :git | |
28 | +# set :branch, :master | |
29 | +# set :format, :pretty | |
30 | +# set :log_level, :debug | |
31 | +# set :keep_releases, 5 | |
32 | + | |
33 | +## Linked Files & Directories (Default None): | |
34 | +# set :linked_files, %w{config/database.yml} | |
35 | +# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | |
36 | + | |
37 | +namespace :puma do | |
38 | + desc 'Create Directories for Puma Pids and Socket' | |
39 | + task :make_dirs do | |
40 | + on roles(:app) do | |
41 | + execute "mkdir #{shared_path}/tmp/sockets -p" | |
42 | + execute "mkdir #{shared_path}/tmp/pids -p" | |
43 | + end | |
44 | + end | |
45 | + | |
46 | + before :start, :make_dirs | |
47 | +end | |
48 | + | |
49 | +namespace :deploy do | |
50 | + desc "Make sure local git is in sync with remote." | |
51 | + task :check_revision do | |
52 | + on roles(:app) do | |
53 | + unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
54 | + puts "WARNING: HEAD is not the same as origin/master" | |
55 | + puts "Run `git push` to sync changes." | |
56 | + exit | |
57 | + end | |
58 | + end | |
59 | + end | |
60 | + | |
61 | + desc 'Initial Deploy' | |
62 | + task :initial do | |
63 | + on roles(:app) do | |
64 | + before 'deploy:restart', 'puma:start' | |
65 | + invoke 'deploy' | |
66 | + end | |
67 | + end | |
68 | + | |
69 | + desc 'Restart application' | |
70 | + task :restart do | |
71 | + on roles(:app), in: :sequence, wait: 5 do | |
72 | + invoke 'puma:restart' | |
73 | + end | |
74 | + end | |
75 | + | |
76 | + before :starting, :check_revision | |
77 | + after :finishing, :compile_assets | |
78 | + after :finishing, :cleanup | |
79 | + after :finishing, :restart | |
80 | +end | |
81 | + | |
82 | +# ps aux | grep puma # Get puma pid | |
83 | +# kill -s SIGUSR2 pid # Restart puma | |
84 | +# kill -s SIGTERM pid # Stop puma | ... | ... |
config/deploy/production.rb
... | ... | @@ -4,9 +4,9 @@ |
4 | 4 | # is considered to be the first unless any hosts have the primary |
5 | 5 | # property set. Don't declare `role :all`, it's a meta role. |
6 | 6 | |
7 | -role :app, %w{deploy@example.com} | |
8 | -role :web, %w{deploy@example.com} | |
9 | -role :db, %w{deploy@example.com} | |
7 | +# role :app, %w{deploy@example.com} | |
8 | +# role :web, %w{deploy@example.com} | |
9 | +# role :db, %w{deploy@example.com} | |
10 | 10 | |
11 | 11 | |
12 | 12 | # Extended Server Syntax |
... | ... | @@ -15,7 +15,7 @@ role :db, %w{deploy@example.com} |
15 | 15 | # server list. The second argument is a, or duck-types, Hash and is |
16 | 16 | # used to set extended properties on the server. |
17 | 17 | |
18 | -server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value | |
18 | +# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value | |
19 | 19 | |
20 | 20 | |
21 | 21 | # Custom SSH Options | ... | ... |