运行 推动使用 Capistrano 3 进行生产
Running rpush on production using capistrano 3
对于运行 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) 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 不是 运行ning,所以您得到了 execute :bundle, :exec, "rpush stop -e #{fetch(:rails_env)}"
的未捕获异常。 IE。为什么 运行 rpush stop
如果不是 运行ning?
相反,首先测试(使用 Capistrano 3 的 test command)pid 文件是否存在于给定路径中,只有 运行 存在才停止,否则 运行 开始:
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
对于运行 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) 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 不是 运行ning,所以您得到了 execute :bundle, :exec, "rpush stop -e #{fetch(:rails_env)}"
的未捕获异常。 IE。为什么 运行 rpush stop
如果不是 运行ning?
相反,首先测试(使用 Capistrano 3 的 test command)pid 文件是否存在于给定路径中,只有 运行 存在才停止,否则 运行 开始:
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