当我跑步时
bundle exec cap production deploy
Capistrano开始执行任务,但在检查任务并退出后停止。
然而,我在服务器上的release文件夹是空的 这是我的deploy.rb:
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, "/home/#{fetch(:user)}/apps1/#{fetch(:application)}"
# Default value for :scm is :git
# set :scm, :git
# 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
# 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, { path2: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 5
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command do
on roles :app do
execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}"
end
end
end
task :setup_config do
on roles :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{fetch(:application)}"
execute "mkdir -p #{shared_path}/config"
execute "mkdir -p #{shared_path}/socket"
end
end
# after 'deploy:setup', 'deploy:setup_config'
# task :symlink_config do
# on roles :app do
# execute "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
# end
# end
# after 'deploy:updated', 'deploy:symlink_config'
desc 'Make sure local git is in sync with remote.'
task :check_revision do
on roles :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts 'WARNING: HEAD is not the same as origin/master'
puts 'Run `git push` to sync changes.'
exit
end
end
end
before 'deploy', 'deploy:check_revision'
end
这是我的控制台日志(my_ip是服务器ip,my_user是我的服务器用户名,my_local_user是我的本地用户名):
rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
ruby-2.3.0
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 my_user@my_ip 0.027s
Uploading /tmp/git-ssh-my_app-production-my_local_user.sh 100.0%
02 chmod 700 /tmp/git-ssh-my_app-production-my_local_user.sh
✔ 02 my_user@my_ip 0.036s
00:00 git:check
01 git ls-remote --heads git@bitbucket.org:my_app/my_app.git
01 b440ec9ce098e4cfb733a39f2f65c898ce579583 refs/heads/master
✔ 01 my_user@my_ip 2.748s
00:02 deploy:check:directories
01 mkdir -p /home/my_user/apps1/my_app/shared /home/my_user/apps1/my_app/releases
✔ 01 my_user@my_ip 0.015s
00:02 deploy:check:linked_dirs
01 mkdir -p /home/my_user/apps1/my_app/shared/log /home/my_user/apps1/my_app/shared/tmp/pids /home/my_user/apps1/my_app/shared/tmp/cache /home/my_user/apps1/my_app/shared/tmp/so…
✔ 01 my_user@my_ip 0.014s
00:02 deploy:check:make_linked_dirs
01 mkdir -p /home/my_user/apps1/my_app/shared/config
✔ 01 my_user@my_ip 0.012s
00:03 deploy:check:linked_files
linked file /home/my_user/apps1/my_app/shared/config/database.yml does not exist on my_ip
如果删除部署目录或当前版本,或更改部署目录,则日志相同。
感谢任何帮助。
答案 0 :(得分:0)
从上面的评论中移出答案:
public function hookActionProductUpdate($params)
{
if ($this->isSaved)
return null;
...
$this->isSaved = true;
}
这似乎是原因(如果确实是日志中的最后一行)。确保位置上限所需的linked file /home/my_user/apps1/my_app/shared/config/database.yml does not exist on my_ip
文件存在。