#!/bin/bash # # /etc/rc.d/init.d/hhvm # # Starts the hhvm daemon # # chkconfig: 345 26 74 # description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP # processname: hhvm ### BEGIN INIT INFO # Provides: hhvm # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop hhvm # Description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP ### END INIT INFO prog="hhvm" lockfile=/var/lock/subsys/$prog pidfile=/var/tmp/${prog}.pid # Source function library. . /etc/init.d/functions #set -x start() { echo -n $"Starting $prog: " hhvm --user nginx --mode daemon && success || failure $"$prog start" RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} } stop() { echo -n $"Shutting down $prog: " killproc -p $pidfile $prog RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } case "$1" in start) start ;; stop) stop ;; status) if [ -d "/proc/$(cat $pidfile 2>/dev/null)" ];then echo "hhvm is running" else echo "hhvm is not running" fi ;; restart) stop start ;; reload|condrestart|probe) echo "$1 - Not supported." ;; *) echo "Usage: hhvm {start|stop|status|reload|restart[|probe]" exit 1 ;; esac exit $?