]> git.pld-linux.org Git - packages/hhvm.git/blob - hhvm-fcgi.init
provide php(core) = 5.6.0
[packages/hhvm.git] / hhvm-fcgi.init
1 #!/bin/sh
2 #
3 # hhvm-fcgi -- startup script for HHVM FastCGI
4 #
5 # chkconfig:    345 80 20
6 #
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
11 #
12
13 # Source function library
14 . /etc/rc.d/init.d/functions
15
16 # Get network config
17 . /etc/sysconfig/network
18
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"
23                 exit 1
24         fi
25 else
26         exit 0
27 fi
28
29 # Set defaults
30 # Default values. This values can be overwritten in '/etc/sysconfig/hhvm-fcgi'
31 DAEMON="/usr/bin/hhvm"
32 NAME="hhvm"
33 CONFIG_FILE="/etc/hhvm/server.hdf"
34 RUN_AS_USER="http"
35 LISTEN_PORT="9000"
36 ADDITIONAL_ARGS=""
37
38 # Get service config - may override defaults
39 [ -f /etc/sysconfig/hhvm-fcgi ] && . /etc/sysconfig/hhvm-fcgi
40
41 PIDFILE="/var/run/hhvm/hhvm-fcgi.pid"
42 DAEMON_ARGS="--config ${CONFIG_FILE} \
43 --user ${RUN_AS_USER} \
44 --mode daemon \
45 -vServer.Type=fastcgi \
46 -vServer.Port=${LISTEN_PORT} \
47 -vPidFile=${PIDFILE} \
48 ${ADDITIONAL_ARGS}"
49
50 # configtest itself
51 # must return non-zero if check failed
52 # output is discarded if checkconfig is ran without details
53 configtest() {
54         start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test
55 }
56
57 # wrapper for configtest
58 checkconfig() {
59         local details=${1:-0}
60
61         if [ $details = 1 ]; then
62                 # run config test and display report (status action)
63                 show "Checking %s configuration" "HHVM FastCGI Daemon"; busy
64                 local out
65                 out=$(configtest 2>&1)
66                 RETVAL=$?
67                 if [ $RETVAL = 0 ]; then
68                         ok
69                 else
70                         fail
71                 fi
72                 [ "$out" ] && echo >&2 "$out"
73         else
74                 # run config test and abort with nice message if failed
75                 # (for actions checking status before action).
76                 configtest >/dev/null 2>&1
77                 RETVAL=$?
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
81                         exit $RETVAL
82                 fi
83         fi
84 }
85
86 start() {
87         # Check if the service is already running?
88         if [ -f /var/lock/subsys/hhvm-fcgi ]; then
89                 msg_already_running "HHVM FastCGI Daemon"
90                 return
91         fi
92
93         checkconfig
94         msg_starting "HHVM FastCGI Daemon"
95         daemon --pidfile $PIDFILE $DAEMON $DAEMON_ARGS
96         RETVAL=$?
97         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hhvm-fcgi
98 }
99
100 stop() {
101         if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
102                 msg_not_running "HHVM FastCGI Daemon"
103                 return
104         fi
105
106         # Stop daemons.
107         msg_stopping "HHVM FastCGI Daemon"
108         killproc --pidfile $PIDFILE $NAME -TERM
109         RETVAL=$?
110         rm -f /var/lock/subsys/hhvm-fcgi
111 }
112
113 condrestart() {
114         if [ ! -f /var/lock/subsys/hhvm-fcgi ]; then
115                 msg_not_running "HHVM FastCGI Daemon"
116                 RETVAL=$1
117                 return
118         fi
119
120         checkconfig
121         stop
122         start
123 }
124
125 RETVAL=0
126 # See how we were called.
127 case "$1" in
128   start)
129         start
130         ;;
131   stop)
132         stop
133         ;;
134   restart)
135         checkconfig
136         stop
137         start
138         ;;
139   try-restart)
140         condrestart 0
141         ;;
142   force-reload)
143         condrestart 7
144         ;;
145   checkconfig|configtest)
146         checkconfig 1
147         ;;
148   status)
149         status --pidfile $PIDFILE hhvm-fcgi hhvm
150         RETVAL=$?
151         ;;
152   *)
153         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
154         exit 3
155 esac
156
157 exit $RETVAL
This page took 0.04533 seconds and 3 git commands to generate.