Commit e3318f850024c3299ab6dadebc8f17564b13c3f7
1 parent
6351f5cd
Exists in
master
and in
1 other branch
more changes for new deploy mode
Showing
3 changed files
with
140 additions
and
42 deletions
Show diff stats
Capfile
| 1 | 1 | # Load DSL and Setup Up Stages |
| 2 | 2 | require 'capistrano/setup' |
| 3 | + | |
| 4 | +# Includes default deployment tasks | |
| 3 | 5 | require 'capistrano/deploy' |
| 4 | 6 | |
| 5 | -require 'capistrano/rails' | |
| 6 | -require 'capistrano/bundler' | |
| 7 | -require 'capistrano/rvm' | |
| 8 | -require 'capistrano/puma' | |
| 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' | |
| 9 | 23 | |
| 10 | 24 | # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. |
| 11 | 25 | Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } | ... | ... |
config/deploy.rb
| 1 | -# -*- encoding : utf-8 -*- | |
| 2 | -# config valid only for Capistrano 3.1 | |
| 3 | -lock '3.2.1' | |
| 1 | +# Change these | |
| 2 | +server '150.165.204.80', port: 22, password: 'l1br4s-l1v3', roles: [:web, :app, :db], primary: true | |
| 4 | 3 | |
| 5 | -server '150.165.204.80', port: 22, roles: [:web, :app, :db], primary: true | |
| 6 | - | |
| 7 | -set :application, 'vlibras-web2' | |
| 8 | 4 | set :repo_url, 'git@git.lavid.ufpb.br:vlibras-web2.git' |
| 9 | 5 | set :application, 'vlibras-web2' |
| 10 | 6 | set :user, 'deployer' |
| 11 | - | |
| 12 | -# Default branch is :master | |
| 13 | -ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call | |
| 14 | - | |
| 15 | 7 | set :puma_threads, [4, 16] |
| 16 | 8 | set :puma_workers, 0 |
| 17 | 9 | |
| 18 | -# Default deploy_to directory is /var/www/my_app | |
| 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 | |
| 19 | 15 | set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}" |
| 20 | -set :deploy_via, :copy | |
| 21 | 16 | set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" |
| 22 | 17 | set :puma_state, "#{shared_path}/tmp/pids/puma.state" |
| 23 | 18 | set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" |
| ... | ... | @@ -28,33 +23,16 @@ set :puma_preload_app, true |
| 28 | 23 | set :puma_worker_timeout, nil |
| 29 | 24 | set :puma_init_active_record, true # Change to false when not using ActiveRecord |
| 30 | 25 | |
| 31 | -set :rails_env, 'production' | |
| 32 | - | |
| 33 | -set :use_sudo, false | |
| 34 | - | |
| 35 | -# Default value for :scm is :git | |
| 36 | -# set :scm, :git | |
| 37 | - | |
| 38 | -# Default value for :format is :pretty | |
| 39 | -# set :format, :pretty | |
| 40 | - | |
| 41 | -# Default value for :log_level is :debug | |
| 42 | -# set :log_level, :debug | |
| 43 | - | |
| 44 | -# Default value for :pty is false | |
| 45 | -set :pty, true | |
| 46 | - | |
| 47 | -# Default value for :linked_files is [] | |
| 48 | -set :linked_files, %w{config/database.yml .env} | |
| 49 | - | |
| 50 | -# Default value for linked_dirs is [] | |
| 51 | -set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | |
| 52 | - | |
| 53 | -# Default value for default_env is {} | |
| 54 | -# set :default_env, { path: "/opt/ruby/bin:$PATH" } | |
| 26 | +## Defaults: | |
| 27 | +# set :scm, :git | |
| 28 | +# set :branch, :master | |
| 29 | +# set :format, :pretty | |
| 30 | +# set :log_level, :debug | |
| 31 | +# set :keep_releases, 5 | |
| 55 | 32 | |
| 56 | -# Default value for keep_releases is 5 | |
| 57 | -set :keep_releases, 3 | |
| 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} | |
| 58 | 36 | |
| 59 | 37 | namespace :puma do |
| 60 | 38 | desc 'Create Directories for Puma Pids and Socket' | ... | ... |
| ... | ... | @@ -0,0 +1,106 @@ |
| 1 | +# -*- encoding : utf-8 -*- | |
| 2 | +# config valid only for Capistrano 3.1 | |
| 3 | +lock '3.2.1' | |
| 4 | + | |
| 5 | +server '150.165.204.80', port: 22, password: 'l1br4s-l1v3', roles: [:web, :app, :db], primary: true | |
| 6 | + | |
| 7 | +set :application, 'vlibras-web2' | |
| 8 | +set :repo_url, 'git@git.lavid.ufpb.br:vlibras-web2.git' | |
| 9 | +set :application, 'vlibras-web2' | |
| 10 | +set :user, 'deployer' | |
| 11 | + | |
| 12 | +# Default branch is :master | |
| 13 | +ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call | |
| 14 | + | |
| 15 | +set :puma_threads, [4, 16] | |
| 16 | +set :puma_workers, 0 | |
| 17 | + | |
| 18 | +# Default deploy_to directory is /var/www/my_app | |
| 19 | +set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}" | |
| 20 | +set :deploy_via, :remote_cache | |
| 21 | +set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock" | |
| 22 | +set :puma_state, "#{shared_path}/tmp/pids/puma.state" | |
| 23 | +set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" | |
| 24 | +set :puma_access_log, "#{release_path}/log/puma.error.log" | |
| 25 | +set :puma_error_log, "#{release_path}/log/puma.access.log" | |
| 26 | +set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) } | |
| 27 | +set :puma_preload_app, true | |
| 28 | +set :puma_worker_timeout, nil | |
| 29 | +set :puma_init_active_record, true # Change to false when not using ActiveRecord | |
| 30 | + | |
| 31 | +set :rails_env, 'production' | |
| 32 | + | |
| 33 | +set :use_sudo, false | |
| 34 | + | |
| 35 | +# Default value for :scm is :git | |
| 36 | +# set :scm, :git | |
| 37 | + | |
| 38 | +# Default value for :format is :pretty | |
| 39 | +# set :format, :pretty | |
| 40 | + | |
| 41 | +# Default value for :log_level is :debug | |
| 42 | +# set :log_level, :debug | |
| 43 | + | |
| 44 | +# Default value for :pty is false | |
| 45 | +set :pty, true | |
| 46 | + | |
| 47 | +# Default value for :linked_files is [] | |
| 48 | +set :linked_files, %w{config/database.yml .env} | |
| 49 | + | |
| 50 | +# Default value for linked_dirs is [] | |
| 51 | +set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | |
| 52 | + | |
| 53 | +# Default value for default_env is {} | |
| 54 | +# set :default_env, { path: "/opt/ruby/bin:$PATH" } | |
| 55 | + | |
| 56 | +# Default value for keep_releases is 5 | |
| 57 | +set :keep_releases, 3 | |
| 58 | + | |
| 59 | +namespace :puma do | |
| 60 | + desc 'Create Directories for Puma Pids and Socket' | |
| 61 | + task :make_dirs do | |
| 62 | + on roles(:app) do | |
| 63 | + execute "mkdir #{shared_path}/tmp/sockets -p" | |
| 64 | + execute "mkdir #{shared_path}/tmp/pids -p" | |
| 65 | + end | |
| 66 | + end | |
| 67 | + | |
| 68 | + before :start, :make_dirs | |
| 69 | +end | |
| 70 | + | |
| 71 | +namespace :deploy do | |
| 72 | + desc "Make sure local git is in sync with remote." | |
| 73 | + task :check_revision do | |
| 74 | + on roles(:app) do | |
| 75 | + unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
| 76 | + puts "WARNING: HEAD is not the same as origin/master" | |
| 77 | + puts "Run `git push` to sync changes." | |
| 78 | + exit | |
| 79 | + end | |
| 80 | + end | |
| 81 | + end | |
| 82 | + | |
| 83 | + desc 'Initial Deploy' | |
| 84 | + task :initial do | |
| 85 | + on roles(:app) do | |
| 86 | + before 'deploy:restart', 'puma:start' | |
| 87 | + invoke 'deploy' | |
| 88 | + end | |
| 89 | + end | |
| 90 | + | |
| 91 | + desc 'Restart application' | |
| 92 | + task :restart do | |
| 93 | + on roles(:app), in: :sequence, wait: 5 do | |
| 94 | + invoke 'puma:restart' | |
| 95 | + end | |
| 96 | + end | |
| 97 | + | |
| 98 | + before :starting, :check_revision | |
| 99 | + after :finishing, :compile_assets | |
| 100 | + after :finishing, :cleanup | |
| 101 | + after :finishing, :restart | |
| 102 | +end | |
| 103 | + | |
| 104 | +# ps aux | grep puma # Get puma pid | |
| 105 | +# kill -s SIGUSR2 pid # Restart puma | |
| 106 | +# kill -s SIGTERM pid # Stop puma | ... | ... |