Ruby on rails 4 使用capistrano 3在生产上运行rpush
为了运行Rpush,我在config/deploy.rb中编写了这篇文章Ruby on rails 4 使用capistrano 3在生产上运行rpush,ruby-on-rails-4,capistrano3,Ruby On Rails 4,Capistrano3,为了运行Rpush,我在config/deploy.rb中编写了这篇文章 after :publishing, 'deploy:restart' after :finishing, 'deploy:cleanup' after :finished, :restart_rpush do on roles(:web) do within release_path do with rails_env: fetch(:rails_env)
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
after :finished, :restart_rpush do
on roles(:web) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, "rpush stop -e #{fetch(:rails_env)}"
execute :bundle, :exec, "rpush start -e #{fetch(:rails_env)}"
end
end
end
end
end
部署时,我遇到以下错误:
DEBUG [76ef4791] * Rpush isn't running?
/home/dev/proteqtor/releases/20150714065629/tmp/rpush.pid does not exist.
Rpush未运行。这个问题的原因可能是什么?我认为这是因为,由于Rpush没有运行,所以您得到了一个未捕获的异常,
execute:bundle,:exec,“Rpush stop-e#{fetch(:rails_env)}”
。也就是说,如果没有运行,为什么要运行rpush stop
相反,首先测试(使用Capistrano 3)pid文件是否存在于给定路径,如果存在,则仅运行stop,否则仅运行start:
desc 'Restart rpush'
task :restart_rpush do
on roles(:web) do
within release_path do
with rails_env: fetch(:rails_env) do
if test('[ -f /path/to/my/pid/file ]')
# Rpush is running
execute :bundle, :exec, "rpush stop -e #{fetch(:rails_env)}"
execute :bundle, :exec, "rpush start -e #{fetch(:rails_env)}"
else
# Rpush is not running
execute :bundle, :exec, "rpush start -e #{fetch(:rails_env)}"
end
end
end
end
end
after :finished, :restart_rpush