Update deploy config

This commit is contained in:
Jesse C. Fisher 2023-07-20 18:34:44 +00:00
parent 1cf9121f0f
commit 5e6ecdfbb5
2 changed files with 27 additions and 10 deletions

View File

@ -26,23 +26,24 @@ append :linked_files, ".env"
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/lift-calculator}
set :rbenv_type, :system # or :user , depends on your rbenv setup
set :rbenv_type, :user # or :system, or :fullstaq (for Fullstaq Ruby), depends on your rbenv setup
# set :rbenv_ruby, '2.6.0'
set :rbenv_ruby, File.read('.ruby-version').strip
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}
append :rbenv_map_bins, 'puma', 'pumactl'
set :rbenv_roles, :all # default value
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :default_env, {
'PATH' => 'PATH=/usr/local/rbenv/bin:./bin:$PATH:./bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl'
'PATH' => 'PATH=$HOME/bin:/usr/local/rbenv/bin:./bin:$PATH:./bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:$HOME/.rbenv/bin'
}
# set :keep_releases, 5
# global rbenv install config
set :rbenv_custom_path, "/usr/local/rbenv"
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_custom_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_custom_path)}/bin/rbenv exec"
# rbenv system global rbenv install config
# set :rbenv_custom_path, "/usr/local/rbenv"
# set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_custom_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_custom_path)}/bin/rbenv exec"
set :nginx_path, '/etc/nginx' # directory containing sites-available and sites-enabled
set :nginx_template, 'config/deploy/nginx_conf.erb' # configuration template
@ -88,3 +89,19 @@ namespace :deploy do
after :finishing, 'deploy:cleanup'
end
namespace :rails do
desc 'Open a rails console `cap [staging] rails:console [server_index default: 0]`'
task :console do
server = roles(:app)[ARGV[2].to_i]
puts "Opening a console on: #{server.hostname}...."
cmd = "ssh #{server.user}@#{server.hostname} -t 'bash -c export PATH=/usr/local/rbenv/bin:./bin:$PATH:./bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:$HOME/.rbenv/bin; cd #{fetch(:deploy_to)}/current && RAILS_ENV=#{fetch(:rails_env)} which ruby'"
# cmd = "ssh #{server.user}@#{server.hostname} -t 'export PATH=/usr/local/rbenv/bin:./bin:$PATH:./bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:$HOME/.rbenv/bin; cd #{fetch(:deploy_to)}/current && RAILS_ENV=#{fetch(:rails_env)} bundle exec rails console'"
puts cmd
exec cmd
end
end

View File

@ -1,15 +1,15 @@
set :stage, :production
set :nginx_server_name, '13.24x7.hk' # optional, defaults to :application
set :nginx_server_name, '13.tendy.zone' # optional, defaults to :application
# Simple Role Syntax
# ==================
# server in each group is considered to be the first
# unless any hosts have the primary property set.
role :app, %w{thirteen@13.24x7.hk}
role :app, %w{thirteen@13.tendy.zone}
# Supports bulk-adding hosts to roles, the primary
role :web, %w{thirteen@13.24x7.hk}
role :db, %w{thirteen@13.24x7.hk}
role :web, %w{thirteen@13.tendy.zone}
role :db, %w{thirteen@13.tendy.zone}
# Extended Server Syntax
# ======================
@ -17,7 +17,7 @@ role :db, %w{thirteen@13.24x7.hk}
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
server '13.24x7.hk', user: 'thirteen', roles: %w{web app db}, my_property: :my_value
server '13.tendy.zone', user: 'thirteen', roles: %w{web app db}, my_property: :my_value
set :ssh_options, { :verbose => :debug }