2014-05-10 20 views
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 

回答

1

使用Capistrano的,你可以运行任何你想要的服务器

task :execute_on_server do 
    on "[email protected]" do 
    execute "some_command" 
    end 
end 

除此之外,你通常把一个.keep文件的目录中必要的,但你不想跟踪,否则。所以当你结帐的应用程序,该文件夹在那里,但“空”。

+0

我使用execute命令创建了tmp文件夹,方法是重新定义deploy:restart task –

相关问题