重新启动应用程序不再使用Cap 3.1和Rails 4

Tod*_*one 1 capistrano ruby-on-rails ruby-on-rails-4 capistrano3

在我们升级到Rails 4和Cap 3.1之前,以下任务正在进行

desc 'Restart application'
task :restart do
  on roles(:web), in: :sequence, wait: 5 do
    execute :touch, release_path.join('tmp/restart.txt')
  end
end
Run Code Online (Sandbox Code Playgroud)

首先,我知道Cap 3.1没有隐式调用:重启,所以我添加了以下内容:

after :publishing, :restart
Run Code Online (Sandbox Code Playgroud)

但是,它尝试"触摸"restart.txt文件失败,以便Apache重新加载应用程序.

cap aborted!
touch stdout: Nothing written
touch stderr: Nothing written
config/deploy.rb:46:in `block (3 levels) in <top (required)>'
config/deploy.rb:45:in `block (2 levels) in <top (required)>'
Tasks: TOP => deploy:restart
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: touch stdout: Nothing written
touch stderr: Nothing written
>
Run Code Online (Sandbox Code Playgroud)

我还需要重启吗?它通常看起来没问题,但我想知道是否可能因为没有找到办法来解决这个问题.

Rus*_*nov 15

有一个类似的问题,试图在服务器上运行此命令并得到一个错误 touch: cannot touch 'myappdir/releases/20140416074158/tmp/restart.txt': No such file or directory,所以我只是添加一行来创建一个release_path/tmp目录:

desc 'Restart application'
task :restart do
  on roles(:web), in: :sequence, wait: 5 do
    execute :mkdir, '-p', "#{ release_path }/tmp"
    execute :touch, release_path.join('tmp/restart.txt')
  end
end
Run Code Online (Sandbox Code Playgroud)