使用进程管理器启动延迟作业时丢失PID文件

Ton*_*ony 6 ruby-on-rails delayed-job bluepill

我正在使用BluePill来管理诸如Rails的延迟作业之类的进程.在BluePill日志中,我收到此消息:

W, [2010-09-27T01:23:20.447053 #19441]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-09-27T01:23:20.447368 #19441]  WARN -- : [fsg_distro:delayed_job] Executing start command: ruby script/delayed_job -e production start
I, [2010-09-27T01:23:20.469165 #19441]  INFO -- : [fsg_distro:delayed_job] Going from down => starting
Run Code Online (Sandbox Code Playgroud)

所以它声称丢失了一个pid文件,但是当BluePill启动延迟作业进程时,不应该创建pid吗?

更新 要更清楚地了解此错误,我可以手动成功运行该命令,但Bluepill无法运行启动命令.当我手动运行它时,它看起来像这样:

rails@george:/srv/fsg_distro/current$ /usr/bin/env RAILS_ENV=production /usr/bin/ruby /srv/fsg_distro/current/script/delayed_job start
delayed_job: process with pid 17564 started. 
Run Code Online (Sandbox Code Playgroud)

当我使用Bluepill运行它时,它看起来像这样:

W, [2010-10-03T21:24:13.943136 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:13.943391 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
I, [2010-10-03T21:24:13.943811 #17326]  INFO -- : [fsg_distro:delayed_job] Going from starting => down
W, [2010-10-03T21:24:14.945274 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:14.945495 #17326]  WARN -- : [fsg_distro:delayed_job] pid_file /srv/fsg_distro/shared/pids/delayed_job.pid does not exist or cannot be read
W, [2010-10-03T21:24:14.945826 #17326]  WARN -- : [fsg_distro:delayed_job] Executing start command: /usr/bin/env RAILS_ENV=production /usr/bin/ruby /srv/fsg_distro/current/script/delayed_job start
W, [2010-10-03T21:24:15.049261 #17326]  WARN -- : [fsg_distro:delayed_job] Start command execution returned non-zero exit code:
W, [2010-10-03T21:24:15.049491 #17326]  WARN -- : [fsg_distro:delayed_job] {:stderr=>"", :exit_code=>1, :stdout=>""} 
I, [2010-10-03T21:24:15.049947 #17326]  INFO -- : [fsg_distro:delayed_job] Going from down => starting 
Run Code Online (Sandbox Code Playgroud)

我的药丸看起来像这样:

APP_ROOT='/srv/fsg_distro'
RAILS_ROOT='/srv/fsg_distro/current'
RAILS_ENV='production'
RUBY_EXEC='/usr/bin/ruby'

Bluepill.application("fsg_distro", :log_file => "/srv/fsg_distro/shared/log/bluepill.log") do |app|
  app.process("delayed_job") do |process|
    process.working_dir = RAILS_ROOT

    process.start_grace_time    = 30.seconds
    process.stop_grace_time     = 30.seconds
    process.restart_grace_time  = 30.seconds

    process.start_command = "/usr/bin/env RAILS_ENV=#{RAILS_ENV} #{RUBY_EXEC} #{RAILS_ROOT}/script/delayed_job start"
    process.stop_command  = "/usr/bin/env RAILS_ENV=#{RAILS_ENV} #{RUBY_EXEC} #{RAILS_ROOT}/script/delayed_job stop"

    process.pid_file = "#{APP_ROOT}/shared/pids/delayed_job.pid"
    process.uid = "deploy"
    process.gid = "deploy"
  end
end 
Run Code Online (Sandbox Code Playgroud)

我的延迟工作脚本看起来像这样:

#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'production'

require File.dirname(__FILE__) + '/../config/environment'
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize 
Run Code Online (Sandbox Code Playgroud)

小智 1

我没有答案,但提出了完全相同的问题。我尝试了很多很多解决方案 - 包括为 init.d 创建启动脚本并从 bluepill 调用它,如另一篇基于 monit 的帖子中所述(http://stackoverflow.com/questions/1226302/how-to-monitor-延迟工作与监控),但没有任何效果。PID 文件始终存在权限问题。以su运行怎么会出现这种情况?

我拥有该代码,并与 www 小组分享。我是否需要创建一个自定义用户才能运行 bluepill?如果是这样,需要什么设置?