Rails 4 - capistrano 3 does not deploy recent commits

We have a production environment for a Rails 4 application with Apache, Phusion Passenger and Capistrano 3, as well as a remote bitbucket repository. Capistrano's automatic deployment "works fine" and runs without error. But when we go to the "current" folder on the remote server and do the "git log" command, the last commits of our remote repository are not loaded.

We tried "git log" in the main folder of our application, same problem.

Our question is, who can push the latest commits of our repo into production? Didn't Capistrano do this by default?

Any idea where this could have come from?

Here is the code for our Capfile, deploy.rb and deploy / production.rb:

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'


require 'rvm1/capistrano3'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }

      

deploy.rb

lock '3.1.0'

set :application, 'XXXXXXX'
set :deploy_user, 'XXXXXXX'

set :repo_url, 'GIT_REPO_URL.XXXXXXX.git'

set :keep_releases, 5

set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.1.2'
set :default_env, { rvm_bin_path: '/usr/local/rvm/bin' }


set :bundle_dir, "/usr/local/bin"

set :ssh_options, {:forward_agent => true}

set :linked_files, %w{config/database.yml config/application.yml}

set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

set :tests, []

set(:config_files, %w(
  apache2.conf
  database.example.yml
  log_rotation
  unicorn.rb
  unicorn_init.sh
))

set :log_level, :debug

set :pty, true

set :assets_roles, [:app]

# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
  unicorn_init.sh
))

# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc.
set(:symlinks, [
  {
    source: "apache2.conf",
    link: "/etc/apache2/sites-enabled/#{fetch(:full_app_name)}"
  },
  {
    source: "unicorn_init.sh",
    link: "/etc/init.d/unicorn_#{fetch(:full_app_name)}"
  },
  {
    source: "log_rotation",
   link: "/etc/logrotate.d/#{fetch(:full_app_name)}"
  }
])


namespace :deploy do
   task :start do ; end
   task :stop do ; end
   desc 'Restart application'
   task :restart do
    on roles(:all), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      execute :touch, release_path.join('restart.txt')
    end
  end

  task :stop_node do
    on roles(:all), in: :sequence do
      #Stop the node_server
      execute "nohup node ./realtime/node_server.js &"
    end
  end
  task :restart_node do
    on roles(:all), in: :sequence do
      #Restart the node_server
      execute "nohup node ./realtime/node_server.js &"
    end

  end
end

# Bundle install configuration
set :bundle_without, %w{development test}.join(' ')
set :bundle_roles, :all
namespace :bundler do
  desc "Install gems with bundler."
  task :install do
    on roles fetch(:bundle_roles) do
      with RAILS_ENV: fetch(:environment) do
        within release_path do
          execute :bundle, "install", "--without #{fetch(:bundle_without)}"
        end
      end
    end
  end
end
before 'deploy:updated', 'bundler:install'
before 'deploy:restart', 'bundler:install'
after 'deploy:updated', 'deploy:publishing'
after 'deploy:restart','deploy:restart_node'

      

expand /production.rb

set :stage, :production
set :branch, "REPO_BRANCH"

set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
set :server_name, "XXXXXXX.com www.XXXXXXXX.com"

set :password, ask('Server password', nil)


server 'XXXXXX.com', user: 'XXXXXX', password: fetch(:password), port: 22,  roles: %w{web app}, primary: true

set :deploy_to, '/PATH/TO/APP'


set :rails_env, :production
set :environment, "production"

set :unicorn_worker_count, 5

set :enable_ssl, false

      

+3


source to share


2 answers


It looks like capistrano keeps a repo / directory in the / var / www /: appname / repo directory, which caches the git repository, so if you change the repo, capistrano won't automatically update.



Nook in repo directory helped

+11


source


You have installed a specific branch to deploy ( set :branch, "REPO_BRANCH"

) and that branch is from a remote git repository. Make sure you move the commits to the right branch of the rebot bitbucket.



+1


source







All Articles