我創建了一個Beanstalkd工作人員腳本(使用Pheanstalk library)來處理上傳時的圖像縮略圖釘,並且想要實施BluePill來監視/守護工作人員腳本,但BluePill無法啓動該過程,只是在開始和結束之間循環下。如何使用BluePill監控PHP腳本?
它甚至可以使用BluePill來監視/守護PHP腳本嗎?我通過Google找到的所有示例配置文件都是針對Rails應用程序的。我比Ruby更喜歡Ruby,並且想嘗試supervisord以外的東西,因爲坦率地說我更喜歡BluePill語法。
這裏是我的BluePill腳本:
Bluepill.application("WorkerThumnail") do |app|
app.process("thumbnail_watch") do |process|
process.start_command = "/usr/local/bin/php /var/www/example.com/staging/shared/tasks/WorkerThumbnail.php"
process.pid_file = "/tmp/beanstalk_thumbnail_worker.pid"
process.daemonize = true
process.start_grace_time = 3.seconds
process.stop_grace_time = 5.seconds
process.restart_grace_time = 8.seconds
###########################################
# Memory and CPU Usage checks to make sure
# we don't have a runaway
###########################################
# Check every 20 seconds to make the CPU usage is below 5%;
# if 3 out of 5 checks failed then restart the process
process.checks :cpu_usage, :every => 20.seconds, :below => 5, :times => [3,5]
# Check every 10 seconds to make the Memory usage is below 100 MB;
# if 3 out of 5 checks failed then restart the process
process.checks :mem_usage, :every => 10.seconds, :below => 100.megabytes, :times => [3,5]
end
end
當我在前臺運行的BluePill腳本,然後我看到下面的輸出重複一遍又一遍,直到我手動殺進程
[warning]: [WorkerThumnail:thumbnail_watch] Executing start command: /usr/local/bin/php
/var/www/example.com/staging/shared/tasks/WorkerThumbnail.php
[info]: [WorkerThumnail:thumbnail_watch] Going from down => starting
[info]: [WorkerThumnail:thumbnail_watch] Going from starting => down
[warning]: [WorkerThumnail:thumbnail_watch] Executing start command: /usr/local/bin/php /var/www/example.com/staging/shared/tasks/WorkerThumbnail.php
[info]: [WorkerThumnail:thumbnail_watch] Going from down => starting
[info]: [WorkerThumnail:thumbnail_watch] Going from starting => down
[warning]: [WorkerThumnail:thumbnail_watch] Executing start command: /usr/local/bin/php /var/www/example.com/staging/shared/tasks/WorkerThumbnail.php
[info]: [WorkerThumnail:thumbnail_watch] Going from down => starting
[info]: [WorkerThumnail:thumbnail_watch] Going from starting => down
[warning]: [WorkerThumnail:thumbnail_watch] Executing start command: /usr/local/bin/php /var/www/example.com/staging/shared/tasks/WorkerThumbnail.php
[info]: [WorkerThumnail:thumbnail_watch] Going from down => starting
[info]: [WorkerThumnail:thumbnail_watch] Going from starting => down
您的工作腳本是否有錯誤?如果通過CLI手動執行,會發生什麼情況? – mway 2011-03-18 16:52:49
另外請記住,CLI使用中的CWD將與通過BluePill作爲守護程序運行時不同,因此如果使用相對目錄,請相應地進行調整。 :) – mway 2011-03-18 16:54:11
手動啓動過程工作正常,並正確地從隊列中抓取作業,並完成任務,所以我相信工作者腳本沒問題。 此外,我已經學會了過去在CLI腳本中使用完整路徑的難題,所以我確保現在就做到這一點。 – grafikchaos 2011-03-18 16:58:02