summaryrefslogtreecommitdiff
blob: 6fd8d8c5da8c148fb6a9ee2d09b9dbe58cc67ff3 (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-www/spawn-fcgi/files/spawn-fcgi-1.1.0.initd,v 1.1 2004/06/26 23:56:56 stuart Exp $

SPAWNFCGI_PID="/var/run/spawn-fcgi.pid"
SPAWNFCGI_CONF="/etc/conf.d/spawn-fcgi.conf"

if [ -r ${SPAWNFCGI_CONF} ]; then
	. ${SPAWNFCGI_CONF}
fi

depend() {
	need net
}
			
start() {
	local my_end

	ebegin "Starting spawn-fcgi"
	export PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS

	EX="${SPAWNFCGI} -p ${FCGIPORT} -f ${FCGIPROGRAM} -u ${USERID} \
		-g ${GROUPID} -C ${PHP_FCGI_CHILDREN}"

	# copy the allowed environment variables
	unset E
	for i in ${ALLOWED_ENV}; do
		E="${E} ${i}=${!i}"
	done
	
	# clean environment and set up a new one
	env - ${E} ${EX} 2>${SPAWNFCGI_PID}
	my_end=$?
	if [ "$my_end" != "0" ]; then
		[ -f ${SPAWNFCGI_PID} ] && rm -f ${SPAWNFCGI_PID}
		eend $my_end
	fi

	#extract parent-process-id and write it back to the file
	FCGI_PPID=`cat ${SPAWNFCGI_PID} | cut -d':' -f4`
	echo ${FCGI_PPID} > ${SPAWNFCGI_PID}
	eend 0
}

stop() {
	ebegin "Stopping spawn-fcgi"
	kill `cat ${SPAWNFCGI_PID}`
	if [ -w ${SPAWNFCGI_PID} ]; then
		rm ${SPAWNFCGI_PID};
	fi
	eend 0
}