我创建了一个Beanstalkd工作脚本(使用Pheanstalk 库)来处理上传时的图像缩略图,并希望实现BluePill来监视/守护工作脚本,但 BluePill 无法启动该过程,只是在启动和关闭之间循环.
甚至可以使用 BluePill 来监控/守护 PHP 脚本吗?我通过 Google 找到的所有示例配置文件都是针对 Rails 应用程序的。我更喜欢 Ruby 而不是 PHP,并且想尝试其他的东西,而不是 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