0

I'm having two PHP scripts acting as RabbitMQ Consumers and i want them to be started and monitored (+ automatically restarted) through monit.

My /etc/monitrc for the two processes looks like this:

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

In fact, monit only startes the first of both processes making ps fax look like this:

 4622 ?        Sl     0:00 monit
 5036 ?        Ss     0:00  \_ /usr/bin/php /home/dev/magento/base/magento2/bin/magento openerp:category:consumer

The second PHP process is never spawned. Monit Status looks like this

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

Could somebody point me to the right direction of how to fix that? Thanks in advance.

1 Answers1

1

You can make a shell script that runs the PHP commands you need, and then you can invoke the shell script from Monit.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • Isn't monit able to spawn multiple PHP Scripts? Since the scripts are running in endless loop i would have to bring them to background. I thought there is a smarter way using monit built-in functionalities. –  Jan 10 '17 at 13:34