我有两个充当 RabbitMQ 消费者的 PHP 脚本,我希望通过 monit 启动和监控它们(+自动重启)。
这两个进程的 /etc/monitrc 如下所示:
check process php-magento-category
matching "openerp:category:consumer"
start program = "/usr/bin/php /home/dev/magento/base/magento2/bin/magento openerp:category:consumer"
as uid cehrig and gid cehrig
check process php-magento-product
matching "openerp:product:consumer"
start program = "/usr/bin/php /home/dev/magento/base/magento2/bin/magento openerp:product:consumer"
as uid cehrig and gid cehrig
事实上,monit 只启动两个进程中的第一个,使 ps fax 看起来像这样:
4622 ? Sl 0:00 monit
5036 ? Ss 0:00 \_ /usr/bin/php /home/dev/magento/base/magento2/bin/magento openerp:category:consumer
第二个 PHP 进程从未生成。Monit Status 如下所示
Process 'php-magento-category'
status Initializing
monitoring status Initializing
monitoring mode active
on reboot start
data collected Tue, 10 Jan 2017 10:50:58
Process 'php-magento-product'
status Execution failed | Does not exist
monitoring status Monitored
monitoring mode active
on reboot start
data collected Tue, 10 Jan 2017 10:51:28
有人能告诉我如何解决这个问题吗?提前谢谢了。
答案1
您可以编写一个运行所需 PHP 命令的 shell 脚本,然后可以从 Monit 调用该 shell 脚本。