Reputation: 91
We have a production environment for a Rails 4 app with Apache, Phusion Passenger, and Capistrano 3, and a remote bitbucket repository. The Capistrano's "cap production deploy" works well, and executes without errors. But when we go the "current" folder on the remote server, and do a "git log" command, the last commits of our remote repository aren't loaded.
We've tried the "git log" in the main folder of our app, same problem.
Our question is, who can we load the last commits of our repo into the production env ? Isn't Capistrano made to do it by default ?
Any idea of where it could come from ?
Here is the code of our Capfile, deploy.rb and deploy/production.rb files :
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'
deploy/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
Upvotes: 3
Views: 1758
Reputation: 1244
Looks like capistrano keeps a repo/ directory in /var/www/:appname/repo which caches the git repo, so if you change the repo capistrano won't auto-update.
Nuking the repo directory did the trick for me
Upvotes: 12
Reputation: 16435
You have set a specific branch for deployment (set :branch, "REPO_BRANCH"
) and this branch is from the remote git repository. Make sure you have pushed the commits to the right branch of the bitbucket repo.
Upvotes: 2