我有兩個紅寶石服務器腳本,powerupserver.rb和outputserver.rb,形式爲:如何使用Bluepill啓動並運行ruby服務器腳本?
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。我主要選擇了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,並檢查其狀態(須藤bluepill狀態),我看到:
$ sudo bluepill status
powerupserver(pid:0): up
outputserver(pid:0): up
所以它被認爲是(儘管pid爲0?這看起來不太好),但我可以看到他們沒有運行/做他們應該做的事情。具有Bluepill知識的人能幫我弄清楚我在這裏做錯了什麼嗎?提前謝謝你!
我們使用bluepill。潛在問題:流程是否自動守護進程?啓動起來很慢嗎?例如,我們必須給獨角獸(+導軌)整整30秒才能啓動,否則Bluepill永遠不會獲得pid。 – d11wtq