Automatically restarting HHVM when it stops responding but process not dead

情到浓时终转凉″ 提交于 2019-12-06 11:15:18

kristapsk posted a solution on Official bug regarding this topic. This is the script he told to add to cron to be executed every 2 minutes.

I have modified it a bit to make it work with prebuilt packages of HHVM.

#! /bin/bash
PID="`cat /var/run/hhvm/pid`"

if [ "$PID" == "" ]; then
    echo No PID, starting up
    /etc/init.d/hhvm start
else
    if [ "`ps ax -o pid | grep $PID`" == "" ]; then
        echo HHVM PID $PID not running, starting up
        # Stop, just in case, if crashed. Else you would get:
        #  * WARNING: hhvm.83 has already been started
        /etc/init.d/hhvm stop
        /etc/init.d/hhvm start
    fi
fi

Regarding your comment on the other answer, a good option when you have a fallback to php and you want to ensure that HHVM is the one that responded is to use the solution from the answer here with one change, in your status script do a check for:

if (defined('HHVM_VERSION')) {
  echo 'status';
}

The two solutions combined will handle all of hhvm's possible ways of crashing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!