Search code examples
phpubuntu-14.04monit

Monit fails restart php5-fpm


I'm on Ubuntu 14.04 LTS with the latest php5-fpm and try to restart it via monit if port 9000 fails.

My config:

check process php5-fpm with pidfile /var/run/php5-fpm.pid
  group www-data
  start program = "service php5-fpm start"
  stop program  = "service php5-fpm stop"
  if failed port 9000 then restart
  if 1 restarts within 5 cycles then alert
  if 3 restarts within 5 cycles then timeout

I got an email from monit if php5-fpm stops, so far so good. But after that I got another one "failed to start [php5-fpm-tcp]" and php5-fpm resides stopped.

I also tried the following start/stop configs:

start program = "/etc/init.d/php5-fpm start"
stop program  = "/etc/init.d/php5-fpm stop"

And:

start program = "/sbin/start-stop-daemon --start --pidfile /var/run/php5-fpm.pid --exec /usr/sbin/php5-fpm"
stop program  = "/sbin/start-stop-daemon --stop --pidfile /var/run/php5-fpm.pid"

But I always get the same "failed to start [php5-fpm-tcp]" email.

Is there another way to start php5-fpm on ubuntu 14.04?


Solution

  • I've done it using to proxy scripts.

    startphpfpm.sh:

    #!/bin/bash
    service php5-fpm start
    

    stopphpfpm.sh:

    #!/bin/bash
    service php5-fpm stop
    

    And the monit-config now uses them instead of /etc/init.d/php5-fpm or service php5-fpm