次の形式の2つの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
開発では、フォアマンを使用してそれらを実行しますが、それはうまく機能します。現在、Bluepillを使用してデーモンとしてバックグラウンドで実行し、監視しようとしています。ForemanにはBluepill構成ファイル(.pillファイル)にエクスポートするオプションがあるため、Bluepillを選択しました。そこで、それを実行してから、必要に応じて.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の知識を持っている人が、私がここで間違っていることを理解するのを手伝ってくれませんか?よろしくお願いします!