问题
Current state is like this: Nginx -> HHVM -> PHP5-FPM.
When HHVM crashes (quite often) it returns 502 error.
I did @fallback workaround to nginx configuration, but I need to manually restart hhvm.
here Automatically restarting HHVM when it stops responding but process not dead some PID listener cron is described, but sometimes hhvm just unresponsive with existing pid.
How to monitor this?
回答1:
I have the exact same problem - HHVM becomes unresponsive randomly (I haven't figured out why yet)
Here is how I monitor HHVM:
I created a simple status.php:
<?php echo 'status' ?>
Then I created status.sh bash file:
#! /bin/bash
STATUS="`timeout -s KILL 13 wget -T 13 -q -O - http://domain.com/status.php`"
if [ "$STATUS" != "status" ]
then
/etc/init.d/hhvm stop
/etc/init.d/hhvm start
fi
Then I created a cron job that runs every minute:
* * * * * /bin/bash /var/www/camera.new/status.sh
You can adjust timeout (currently - 13s). I think if HHVM doesn't run the simple status.php file for 13s it is time to restart.
回答2:
How about just monitoring your website. With WDT.io you'd create an outbound watchdog timer with your website's address so it would be tested every minute and alert you if it returns the 502 or any other error. That would have the advantage of also finding out if there're any other problems besides HHVM.
来源:https://stackoverflow.com/questions/36025265/how-to-handle-hhvm-crash-or-when-it-becomes-unresponsive