我的Capistrano任务失败
No such file or directory @ rb_sysopen - /home/blog/pids/grantb.blog.staging.pid`
以下是我的命令提示符:
证明该文件确实存在的证据[blog@grantb current]$ ls /home/blog/pids/grantb.blog.staging.pid
/home/blog/pids/grantb.blog.staging.pid
[blog@grantb current]$ irb
2.1.0 :001 > File.read("/home/blog/pids/grantb.blog.staging.pid").to_i
=> 936
这是部分任务:
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
pid_file = fetch(:pid_file)
puts "PID_FILE name: #{pid_file}"
# outputs 'PID_FILE name: /home/blog/pids/grantb.blog.staging.pid'
execute "/bin/ls #{pid_file}"
# outputs '/home/blog/pids/grantb.blog.staging.pid'
execute "/bin/ls #{pid_file}"
# outputs '936'
pid = File.read(pid_file).to_i
# Exception while executing on host x.x.x.x: No such file or directory @ rb_sysopen - /home/blog/pids/grantb.blog.staging.pid
# WHAT THE HELL!
谁能告诉我哪里出错?
答案 0 :(得分:4)
想出来。
File.read()
正在我的本地计算机上执行,而不是在远程计算机上执行。啊。
我需要做的是这样的事情:
within release_path do
execute "cat #{pid_file}"
end
我的实际任务是:
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
pid_file = fetch(:pid_file)
within release_path do
execute "((ls #{pid_file} && ps -p `cat #{pid_file}`) && kill -9 `cat #{pid_file}`) || true"
execute "(ls #{pid_file} && /bin/rm #{pid_file}) || true"
# RESTART COMMAND GOES HERE
end
end
end