Skip to content

Instantly share code, notes, and snippets.

@tomazzaman
Last active September 22, 2016 08:23
Show Gist options
  • Save tomazzaman/13da35056017d7b8cf00 to your computer and use it in GitHub Desktop.
Save tomazzaman/13da35056017d7b8cf00 to your computer and use it in GitHub Desktop.
Restart HHVM with Monit
# This file should be in /etc/monit/conf.d
check process hhvm with pidfile /var/run/hhvm/pid
group hhvm
# Start program calls our custom script from above
start program = "/usr/local/sbin/start_hhvm.sh"
stop program = "/usr/sbin/service hhvm stop"
if failed unixsocket /var/run/hhvm/hhvm.sock then restart
if mem > 400.0 MB for 1 cycles then restart
if 5 restarts with 5 cycles then timeout
#!/bin/bash
# This file should be saved in /usr/local/sbin
# It must exist because sometime a crashed process
# leaves a socket behind, rendering it unstartable
# So what we do is test whether the socket file
# leftover is there and delete it. Also, make sure
# this file is executable: $ chmod +x start_hhvm.sh
SOCKET=/var/run/hhvm/hhvm.sock
if [ -e $SOCKET ];
then
rm -f $SOCKET
fi
/usr/sbin/service hhvm start
exit 0;
@Seb-
Copy link

Seb- commented Aug 17, 2016

For the record, I've had success with using the "restart" /usr/sbin/service hhvm restart into the "start program" directive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment