config/deploy.rb
# config valid only for Capistrano 3.1
lock '3.3.5'
set :application, 'application'
set :repo_url, 'ssh url for gtihub-repo'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :rvm_type, :system
set :rvm_ruby_version, 'ruby-2.2.2'
# set :rbenv_type, :user # or :system, depends on your rbenv setup
# set :rbenv_ruby, '2.2.0'
# set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
# set :rbenv_map_bins, %w{rake gem bundle ruby rails}
# set :rbenv_roles, :all # default value
# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/var/www/rails_apps/#{fetch(:application)}"
set :deploy_user, 'username'
set :use_sudo, false
set :password, ask('Server password:', nil, echo: false)
set :branch, ENV['REVISION'] || ENV['BRANCH_NAME'] || 'release2'
set :ssh_options, {
forward_agent: true,
# verbose: :debug,
# user: fetch(:deploy_user),
# password: fetch(:password)
}
# Default value for :scm is :git
set :scm, :git
set :bundle_binstubs, nil
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/application}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
set :tmp_dir, "/home/username/tmp"
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_access.log"
set :puma_error_log, "#{shared_path}/log/puma_error.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 1
set :puma_worker_timeout, nil
set :puma_init_active_record, false
set :puma_preload_app, false
set :puma_prune_bundler, true
set :nginx_config_name, 'application'
# set :nginx_sites_available_path, "/usr/local/nginx/sites-available"
# set :nginx_sites_enabled_path, "/usr/local/nginx/sites-enabled"
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
config/deploy/production.rb
server 'server-address', user: 'username', roles: %w{web app db}
set :nginx_server_name, 'server-address'
set :rails_env, :production