gpt4 book ai didi

ruby-on-rails - 使用进程管理器启动延迟作业时缺少 PID 文件

转载 作者:行者123 更新时间:2023-12-04 15:37:28 28 4
gpt4 key购买 nike

我正在使用 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

因此,它声称缺少 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.

当我使用 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

我的药丸看起来像这样:
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

我的延迟作业脚本如下所示:
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'production'

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

最佳答案

如果你守护了delayed_job(你是),那么你必须自己为它生成一个pid文件,或者让delayed_job为你做,那么bluepill希望找到pid文件一次grace_start_time已通过。

如果您在前台运行 delay_job,并且您告诉 bluepill 为您守护进程,那么 bluepill 将生成 pid 文件。

您不能既监视自守护进程又让 bluepill 创建一个 pid 文件。它是一个或另一个。

关于ruby-on-rails - 使用进程管理器启动延迟作业时缺少 PID 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3800562/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com