我有两个 ruby 服务器脚本 powerupserver.rb 和 outputserver.rb,格式如下:
require '/Library/WebServer/sample_app/config/environment'
# more requires
@server = TCPServer.open(port_number)
loop do
Thread.start(@server.accept) do |sock|
# do stuff
end
end
在开发中,我使用 Foreman 来运行它们,效果很好。现在我正在尝试使用 Bluepill 作为守护进程在后台运行和监视它们。我选择 Bluepill 主要是因为 Foreman 可以选择导出到 Bluepill 配置文件(.pill 文件)。所以我这样做了,然后根据需要更改了 .pill 文件以获得以下内容:
Bluepill.application("sample_app", :foreground => false, :log_file => "/var/bluepill/log/bluepill.log") do |app|
app.process("powerupserver") do |process|
process.start_command = "ruby powerupserver.rb"
process.working_dir = "/Library/WebServer/sample_app"
process.pid_file = "/var/bluepill/pids/powerupserver-1.pid"
process.daemonize = true
process.stdout = process.stderr = "/var/bluepill/log/powerupserver-1.log"
process.start_grace_time = 3.seconds
process.stop_grace_time = 5.seconds
process.restart_grace_time = 8.seconds
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
process.checks :cpu_usage, :every => 10.seconds, :below => 5, :times => 3
process.checks :mem_usage, :every => 10.seconds, :below => 100.megabytes, :times => [3,5]
process.checks :flapping, :times => 2, :within => 30.seconds, :retry_in => 7.seconds
end
# more lines here mimicking above, but for server script 'outputserver.rb'
end
当我加载这个 .pill 并检查状态(sudo bluepill status)时,我看到:
$ sudo bluepill status
powerupserver(pid:0): up
outputserver(pid:0): up
所以它应该是向上的(尽管 pid 为 0?这当然看起来不太好),但我可以看到他们没有运行/做他们应该做的事情。有 Bluepill 知识的人可以帮我弄清楚我在这里做错了什么吗?非常感谢您提前!