Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano deploys not pulling latest commits

I'm deploying a Rails app with Capistrano, to an Ubuntu server (EC2).

When I deploy, with --trace, everything appears to go fine.

When I look at the revisions log on the server, it shows the latest commit hash was used on the most recent deploy, however, when I go into that latest release directory (yes I confirmed that a new release directory was created and that I'm in that one) it doesn't have the most recent commits.

If I do a 'git pull origin master' from with the new release directory on the server, of course it pulls the latest commits.

Any idea why the git pull wouldn't be happening on the Capistrano deploy?

EDIT: Here's the deploy.rb file:

lock "~> 3.14.0"
set :pty, true
set :application, "123abc"
set :repo_url, "[email protected]:123/abc.git  "

# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
set :branch, "master"

set :rbenv_ruby, File.read('.ruby-version').strip

append :linked_files, "config/secrets.yml"

append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets"

namespace :deploy do

  before :compile_assets, :force_cleanup_assets do
    on release_roles(fetch(:assets_roles)) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :rake, 'assets:clobber'
        end
      end
    end
  end

  app_service_name = "#{fetch(:application)}-#{fetch(:stage)}"

  services = ["#{app_service_name}-workers"]

  desc "Restart application"
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :sudo, :systemctl, :stop, app_service_name
            sleep 1
      execute :sudo, :systemctl, :start, app_service_name
      # execute :sudo, :systemctl, :restart, app_service_name
    end
  end

  desc "Restart Workers"
  task :restart_services do
    on roles(:app), in: :sequence, wait: 5 do
      services.each { |service| execute "sudo systemctl restart #{service}" }
    end
  end

  desc "Start Workers"
  task :start_services do
    on roles(:app), in: :sequence, wait: 5 do
      services.each { |service| execute "sudo systemctl start #{service}" }
    end
  end

  desc "Stop Workers"
  task :stop_services do
    on roles(:app), in: :sequence, wait: 5 do
      services.each { |service| execute "sudo systemctl stop #{service}" }
    end
  end
end

after "deploy:publishing", "deploy:restart"
after "deploy:publishing", "deploy:restart_services"
like image 775
99miles Avatar asked Aug 18 '20 15:08

99miles


1 Answers

Is your organization using a proxy with ca certificate?. Are you pulling from github site using SSL or from another git clone with a self signing certificate?. Please try to su to the user used for the deployment, and attempt git pull, to see if it works?. Are you using Tokens to authenticate or credentials or certificates?. I would attempt to tcpdump to see what's going on, if effectively it attempts to connect to github. Your deploy works with full clone or pull?. Can you deploy using full clone?. Are you using SSH or HTTPS, and default or special ports?.

Can you publish the trace, or at least check that you don't have something like:

Connection refused - connect(2)

I guess that the ending spaces after your repourl are not in your final file.

Cheers

like image 52
Carles Mateo Avatar answered Oct 06 '22 00:10

Carles Mateo