我正在使用带有Capistrano 2.x的Rails 3.2,并且我已经安装了部署脚本。几天前一切正常。但是我注意到,我们的新代码实际上并没有用于生产。它肯定被合并到项目的github上的正确分支。而且,在cap:deploy的输出中,我甚至看到它试图检查最新提交的正确sha引用。但是,文件永远不会实际更新。我的部署脚本如下,以及运行cap:deploy的一些输出。
部署脚本
require "bundler/capistrano"
# General
set :application, "foo"
set :domain, "foo.com"
set :user, "deploy"
set :runner, "deploy"
set :use_sudo, false
set :deploy_to, "/var/www/#{application}"
set :release_path, "/var/www/#{application}/current"
set :repository_cache, "#{application}_cache"
set :environment, "production"
# Roles
role :web, domain
role :app, domain
role :db, domain, :primary => true
# GIT
set :repository, "git@github.com:foo/bar.git"
set :branch, "release"
set :keep_releases, 3
set :deploy_via, :remote_cache
set :scm, :git
# SSH
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
ssh_options[:paranoid] = true # comment out if it gives you trouble. newest net/ssh needs this set.
######## Callbacks - No More Config ########
before "deploy", "deploy:backup_db"
before "deploy", "deploy:copy_ck_editor_assets"
after 'deploy:create_symlink', 'deploy:cleanup' # makes sure there's only 3 deployments, deletes the extras
after "deploy", "deploy:migrate"
after "deploy", "deploy:put_back_ck_editor_assets"
# Custom Tasks
namespace :deploy do
task(:start) {}
task(:stop) {}
desc "Restart Application"
task :restart, :roles => :web, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Back up db"
task :backup_db do
puts "Backing up the database"
run "cd #{release_path}; RAILS_ENV=production bundle exec rake db:data:backup"
puts "Backed up DB"
end
desc "Copy CK Editor assets"
task :copy_ck_editor_assets do
puts "copying assets"
run "cd #{release_path}; cp -R public/ckeditor_assets/ ~"
end
desc "Putting CK Editor assets back"
task :put_back_ck_editor_assets do
puts "putting assets back"
run "cd #{release_path}; cp -R ~/ckeditor_assets public/"
end
end
我相信这是封面的相关摘录:部署输出......
2014-01-09 23:14:11 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git@github.foo/bar.git release"
command finished in 1841ms
* executing "if [ -d /var/www/bar/shared/bar_cache ]; then cd /var/www/bar/shared/bar_cache && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 4dbce9382fb4e9b532bf26c71a731e35b3970966 && git clean -q -d -x -f; else git clone -q -b release git@github.com:foo/bar.git /var/www/bar/shared/bar_cache && cd /var/www/bar/shared/bar_cache && git checkout -q -b deploy 4dbce9382fb4e9b532bf26c71a731e35b3970966; fi"
servers: ["bar.com"]
[bar.com] executing command
command finished in 3369ms
copying the cached version to /var/www/bar/current
* executing "cp -RPp /var/www/bar/shared/bar_cache /var/www/bar/current && (echo 4dbce9382fb4e9b532bf26c71a731e35b3970966 > /var/www/bar/current/REVISION)"
sha哈希是正确的。并且在部署过程中没有任何错误被抛出。这个sha hash肯定有我想要的git repo。但是我在我的发行版文件夹中看到的只是较旧的东西,而我当前的文件夹肯定有旧版本(比如几天之久)。
这里的任何想法都非常感激...我完全不确定如何解决这个问题,因为实际上没有任何错误,并且它仅在几天前工作,而且部署脚本没有任何变化。
此外,如果它有帮助...我几天前做了主应用程序目录的 chmod到755 (在其下发布和当前文件夹)。那就是解决我们遇到的另一个问题。
感谢!!!