-
-
Save gerard-kanters/b54c297bcddb4d18316f to your computer and use it in GitHub Desktop.
HHVM init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# hhvm Startup script for the HipHop Server | |
# | |
# chkconfig: - 85 15 | |
# description: HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP | |
# processname: hhvm | |
# config: /etc/php.ini | |
# config: /etc/hhvm/server.ini | |
# pidfile: /var/run/hhvm/hhvm.pid | |
# | |
### BEGIN INIT INFO | |
# Provides: hhvm | |
# Short-Description: start and stop HipHop Server | |
# Description: HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP | |
### END INIT INFO | |
HHVM=${HHVM-/usr/local/bin/hhvm} | |
prog=hhvm | |
lockfile=${LOCKFILE-/var/lock/subsys/hhvm} | |
pidfile=${PIDFILE-/var/run/hhvm/hhvm.pid} | |
MODE=daemon | |
USER=apache | |
RETVAL=0 | |
STOP_TIMEOUT=${STOP_TIMEOUT-10} | |
CONFIG1=/etc/hhvm/server.ini | |
#CONFIG2=/etc/hhvm/php.ini | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
start() { | |
echo -n $"Starting $prog: " | |
#daemon ${HHVM} --mode ${MODE} --user ${USER} -c ${CONFIG1} -c ${CONFIG2} ${ARGS} | |
daemon ${HHVM} --mode ${MODE} --user ${USER} -c ${CONFIG1} ${ARGS} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && touch ${lockfile} | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $HHVM | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${lockfile} ${PID} | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status -p ${pidfile} $HHVM | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart}" | |
RETVAL=2 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script can be used in /etc/init.d to run hhvm as a service and let it start in the different run levels on Linux. Important is that you need to define the PID in /etc/hhvm/server.ini or the service cannot be stopped or restarted.
We tested with php.ini and server.ini but since hhvm is moving most of the ini settings into the last it is better to use that. Not all php.ini setting are recognised yet but have an undocumented counterpart in hhvm.