3 # hhvm-fcgi -- startup script for HHVM FastCGI
7 # description: Starts The HHVM FastCGI Daemon
8 # processname: hhvm-fcgi
9 # config: /etc/hhvm/server.hdf
10 # pidfile: /var/run/hhvm/hhvm-fcgi.pid
13 # Source function library
14 . /etc/rc.d/init.d/functions
17 . /etc/sysconfig/network
19 # Check that networking is up.
20 if is_yes "${NETWORKING}"; then
21 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
22 msg_network_down "HHVM FastCGI Daemon"
30 # Default values. This values can be overwritten in '/etc/sysconfig/hhvm-fcgi'
31 DAEMON="/usr/bin/hhvm"
33 CONFIG_FILE="/etc/hhvm/server.hdf"
38 # Get service config - may override defaults
39 [ -f /etc/sysconfig/hhvm-fcgi ] && . /etc/sysconfig/hhvm-fcgi
41 PIDFILE="/var/run/hhvm/hhvm-fcgi.pid"
42 DAEMON_ARGS="--config ${CONFIG_FILE} \
43 --user ${RUN_AS_USER} \
45 -vServer.Type=fastcgi \
46 -vServer.Port=${LISTEN_PORT} \
47 -vPidFile=${PIDFILE} \
51 # must return non-zero if check failed
52 # output is discarded if checkconfig is ran without details
54 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test
57 # wrapper for configtest
61 if [ $details = 1 ]; then
62 # run config test and display report (status action)
63 show "Checking %s configuration" "HHVM FastCGI Daemon"; busy
65 out=$(configtest 2>&1)
67 if [ $RETVAL = 0 ]; then
72 [ "$out" ] && echo >&2 "$out"
74 # run config test and abort with nice message if failed
75 # (for actions checking status before action).
76 configtest >/dev/null 2>&1
78 if [ $RETVAL != 0 ]; then
79 show "Checking %s configuration" "HHVM FastCGI Daemon"; fail
80 nls 'Configuration test failed. See details with %s "checkconfig"' $0
87 # Check if the service is already running?
88 if [ -f /var/lock/subsys/hhvm-fcgi ]; then
89 msg_already_running "HHVM FastCGI Daemon"
94 msg_starting "HHVM FastCGI Daemon"
95 daemon --pidfile $PIDFILE $DAEMON $DAEMON_ARGS
97 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hhvm-fcgi
101 if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
102 msg_not_running "HHVM FastCGI Daemon"
107 msg_stopping "HHVM FastCGI Daemon"
108 killproc --pidfile $PIDFILE $NAME -TERM
110 rm -f /var/lock/subsys/hhvm-fcgi
114 if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
115 msg_not_running "HHVM FastCGI Daemon"
126 # See how we were called.
145 checkconfig|configtest)
149 status --pidfile $PIDFILE hhvm-fcgi hhvm
153 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"