0
我按照Capistrano上的说明设置了部署配置,并且我现在可以在git中将代码部署到我的Web服务器。但由于tmp文件夹不在git存储库中,Capistrano似乎无法重新启动我的Ruby-On-Rails应用程序(通过触摸需要tmp文件夹存在的tmp/restart.txt)。通过Capistrano 3.x部署后Rails应用程序不会自动重新启动
我该怎么办?我应该将tmp文件夹添加到git repo中吗?或者如果Capistrano不存在,Capistrano是否可以创建该文件夹?
解决方案:
Rake::Task["deploy:restart"].clear_actions
namespace :deploy do
task :restart do
on roles(:web) do |host|
execute "mkdir -p #{fetch(:deploy_to)}/current/tmp"
info "create folder #{fetch(:deploy_to)}/current/tmp"
execute "touch #{fetch(:deploy_to)}/current/tmp/restart.txt"
end
end
end
我使用execute命令创建了tmp文件夹,方法是重新定义deploy:restart task –