Rails application does not get restarted automatically after deployment through Capistrano 3.x

StackOverflow https://stackoverflow.com/questions/23579957

  •  19-07-2023
  •  | 
  •  

質問

I followed instructions on Capistrano to setup deployment configuraion, and I can deploy the code in git to my web server right now. But because the tmp folder is not in the git repository, Capistrano seems not be able to restart my Ruby-On-Rails application (by touching tmp/restart.txt, which requires the tmp folder to exist).

What I should do? Should I add the tmp folder into git repo? or is there any way that Capistrano can create this folder if it does not exist?

Solution:

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
役に立ちましたか?

解決

by using capistrano, you can run whatever you want on the server

task :execute_on_server do
  on "root@example.com" do
    execute "some_command"
  end
end

other than that, you usually put a .keep file in a directory that is necessary but that you do not want to track otherwise. so when you checkout the application, the folder is there but "empty".

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top