blob: 1e184ae39c269de29ea90b0045d817d444bdeb0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: hhvm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts The HHVM FastCGI Daemon
### END INIT INFO
DAEMON=/usr/bin/hhvm
PIDFILE=/var/run/hhvm/pid
hhvm_SOCKET=/var/run/hhvm/sock
hhvm_GROUP=${hhvm_GROUP:-apache}
CONFIG_FILE="/etc/hhvm/server.ini"
SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini"
DAEMON_ARGS="--config ${SYSTEM_CONFIG_FILE} \
--config ${CONFIG_FILE} \
-vPidFile=${PIDFILE}"
do_stop () {
try=0
if [ ! -r $2 ]; then
echo "warning, no pid file found - HHVM is not running?"
exit 1
fi
PID=`cat $2`
kill $1 $PID
# Waiting for HHVM to shutdown
while test $try -lt 35
do
if ps -p $PID | grep -q $PID
then
echo -n .
try=`expr $try + 1`
sleep 1
else
try=''
break
fi
done
if [ -n "$try" ]
then
echo " failed. Use force-quit"
exit 1
else
rm -f $2
echo " done"
fi
}
wait_for_pid () {
try=0
while test $try -lt 35
do
if [ -f "$1" ] ; then
try=''
break
fi
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting HHVM "
if [ -r $PIDFILE ]; then
echo "warning, pid file found - HHVM is already running?"
exit 1
fi
echo
$DAEMON --mode daemon $DAEMON_ARGS
if [ "$?" != 0 ]
then
echo "Failed"
exit 1
fi
wait_for_pid $PIDFILE
if [ -n "$try" ] ; then
echo " failed"
exit 1
fi
# Set the socket permissions if HHVM uses UDS
if [ -S "$hhvm_SOCKET" ]
then
chgrp $hhvm_GROUP $hhvm_SOCKET
fi
echo " done"
;;
stop)
echo -n "Stopping HHVM "
do_stop -QUIT $PIDFILE
;;
force-quit)
echo -n "Terminating HHVM "
do_stop -TERM $PIDFILE
;;
status)
if [ ! -r $PIDFILE ]
then
echo "HHVM is stopped"
exit 0
fi
PID=`cat $PIDFILE`
if ps -p $PID | grep -q $PID
then
echo "HHVM (pid $PID) is running..."
else
echo "HHVM dead but pid file exists"
fi
;;
restart)
sh $0 stop
sh $0 start
;;
reload)
echo -n "Reload service HHVM "
if [ ! -r $PIDFILE ]
then
echo "warning, no pid file found - HHVM is not running?"
exit 1
fi
kill -USR2 `cat $PIDFILE`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-quit}" >&2
exit 1
;;
esac
|