0

我创建了一个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
4

1 回答 1

0

为后代:

请记住,CLI 使用的 CWD 与通过 BluePill 作为守护程序运行时的 CWD 不同,因此如果您使用的是相对目录,请进行相应调整。

如果这最终不是真正的问题,请随时更新。

于 2011-03-18T17:55:09.573 回答