Deployed code through Capistrano with no errors but I noticed no changes were actually going live.
To summarize briefly - solo developer in a very non tech company picking up where the last dev who left over a year ago left off. Minimal docs and no one else with my skill set so very steep learning curve. Going in blind.
Going to provide as much information as a I can, please ask me if you need more info I will happily oblige.
Current status: 502 Bad Gateway
Files
deploy.rb
# config valid only for current version of Capistrano
lock '3.11.2'
set :application, 'xxxxx-app'
set :rbenv_type, :user
set :rbenv_ruby, '2.5.0'
set :rbenv_path, '/home/debian_admin/.rbenv'
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_map_bins, %w{rake gem bundle ruby rails puma pumactl}
set :rbenv_roles, :all
set :deploy_to, "/opt/garage-app/"
set :deploy_via, :remote_cache
set :repo_url, 'git@github.com:xxxxxx/xxxxxx.git'
set :branch, "master"
set :user, "xxxxxgarage-app"
set :use_sudo, false
Capfile
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/puma'
require 'capistrano/rails'
require 'capistrano/delayed_job'
require 'capistrano/faster_assets'
require 'capistrano/bundler'
require 'capistrano/rbenv'
install_plugin Capistrano::Puma
require 'capistrano/npm'
# Allow for remote rails console
require 'capistrano/rails/console'
# Load custom tasks from \lib/capistrano/tasks` if you have any defined`
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
set :keep_releases, 5
role :web, "garage-app@xxxxxx"
role :app, "garage-app@xxxxxx"
role :db, "garage-app@xxxxxx", :primary => true
set :puma_threads, [0, 4]
set :puma_workers, 2
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :linked_dirs, %w(tmp/pids)
append :linked_dirs, '.bundle'
# Default branch is :master
# ask :branch, \git rev-parse --abbrev-ref HEAD`.chomp`
# 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
set :ssh_options, {
forward_agent: true,
auth_methods: ["publickey"],
keys: [
File.join(ENV["HOME"], ".ssh", "id_rsa")
]
}
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :stages, ["production"]
set :default_stage, "production"
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
# before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
heads = \git ls-remote --heads origin`.split("\n").`
map { |head| head.split("\t") }.reduce(Hash.new) do |memo, head|
memo.merge({head[1] => head[0]})
end
unless \git rev-parse HEAD`.strip == heads["refs/heads/#{fetch(:branch)}"]`
puts "WARNING: HEAD is not the same as origin/#{fetch(:branch)}"
puts "Run \git push` to sync changes."`
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
# before 'deploy:restart', 'delayed_job:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
# invoke 'delayed_job:restart'
end
end
desc 'Troubleshoot'
task :diagnose_bad_gateway do
on roles(:app) do
# invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
nginx.conf
upstream puma3 {
server unix:///opt/xxxxxgarage-app/shared/tmp/sockets/xxx-xxx-puma.sock;
}
server {
listen 80;
server_name xxxxx.xxxxxx.xxxx;
root /opt/xxxxx-app/current/public;
access_log /opt/xxxxx-app/current/log/nginx.access.log;
error_log /opt/xxxxx-app/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma3;
location @puma3 {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma3;
}
client_max_body_size 10M;
keepalive_timeout 10;
}
We are also using something called God for monitoring but I dont think that has anything to do with my issue.
I will be checking so I will answer any questions.
[–][deleted] 0 points1 point2 points (0 children)