/[gentoo-x86]/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1
Gentoo

Contents of /www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Apr 2 18:55:13 2012 UTC (2 years, 8 months ago) by pacho
Branch: MAIN
CVS Tags: HEAD
Don't assume /var/run/spawn-fcgi is always present, bug #400899 by Maxim Kammerer.

(Portage version: 2.1.10.54/cvs/Linux x86_64)

1 #!/sbin/runscript
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.12 2010/10/22 17:51:58 bangert Exp $
5
6 PROGNAME=${SVCNAME#*.}
7 SPAWNFCGI=/usr/bin/spawn-fcgi
8 PIDPATH=/var/run/spawn-fcgi
9 PIDFILE=${PIDPATH}/${PROGNAME}
10
11 depend() {
12 need net
13 }
14
15 start() {
16 local X E OPTIONS i RETVAL FCGI_PROGRAM_EXEC
17 FCGI_PROGRAM_EXEC=$(echo ${FCGI_PROGRAM} | awk "{print \$1}")
18
19 if [ "${SVCNAME}" = "spawn-fcgi" ]; then
20 eerror "You are not supposed to run this script directly. Create a symlink"
21 eerror "for the FastCGI application you want to run as well as a copy of the"
22 eerror "configuration file and modify it appropriately like so..."
23 eerror
24 eerror " ln -s spawn-fcgi /etc/init.d/spawn-fcgi.trac"
25 eerror " cp /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.trac"
26 eerror " `basename "${EDITOR}"` /etc/conf.d/spawn-fcgi.trac"
27 eerror
28 return 1
29 fi
30
31 if [ ! -z "${FCGI_SOCKET}" ] && [ ! -z "${FCGI_PORT}" ]; then
32 eerror "Only one of the two may be defined:"
33 eerror " FCGI_SOCKET=${FCGI_SOCKET}"
34 eerror " FCGI_PORT=${FCGI_PORT}"
35 return 1
36 fi
37
38 if [ -z "${FCGI_PROGRAM}" ]; then
39 eerror "You need to specify which \$FCGI_PROGRAM"
40 eerror "you want to start."
41 eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
42 return 1
43 fi
44
45 if [ ! -x "${FCGI_PROGRAM_EXEC}" ]; then
46 eerror "The file specified as \$FCGI_PROGRAM"
47 eerror "does not exist or is not executable."
48 eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
49 return 1
50 fi
51
52 if [ -z "${FCGI_ADDRESS}" ]; then
53 FCGI_ADDRESS=127.0.0.1
54 fi
55
56 if [ -z "${FCGI_CHILDREN}" ]; then
57 FCGI_CHILDREN=1
58 fi
59
60 if [ -n "${FCGI_CHROOT}" ]; then
61 OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
62 fi
63
64 if [ -n "${FCGI_DIR}" ]; then
65 OPTIONS="${OPTIONS} -d ${FCGI_DIR}"
66 fi
67
68 if [ -n "${FCGI_USER}" ] && [ "${FCGI_USER}" != "root" ]; then
69 OPTIONS="${OPTIONS} -u ${FCGI_USER}"
70 fi
71
72 if [ -n "${FCGI_GROUP}" ] && [ "${FCGI_GROUP}" != "root" ]; then
73 OPTIONS="${OPTIONS} -g ${FCGI_GROUP}"
74 fi
75
76 if [ -n "${FCGI_EXTRA_OPTIONS}" ]; then
77 OPTIONS="${OPTIONS} ${FCGI_EXTRA_OPTIONS}"
78 fi
79
80 unset E
81 for i in ${ALLOWED_ENV}; do
82 local j
83 eval j=$(echo \$"$i")
84 [ -n "${j}" ] && E="${E} ${i}=${j}"
85 done
86
87 ebegin "Starting FastCGI application ${PROGNAME}"
88 checkpath -q -d -m 700 /var/run/spawn-fcgi
89 X=0
90 while [ $X -lt ${FCGI_CHILDREN} ]; do
91 X=$(($X+1))
92 local P SOCKET_OPTION INET_OPTION
93 P=${PIDFILE}-${X}.pid
94 [ -n "${FCGI_SOCKET}" ] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
95 [ -n "${FCGI_PORT}" ] && INET_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
96
97 env -i ${E} /sbin/start-stop-daemon --start --pidfile ${P} --exec ${SPAWNFCGI} \
98 --name ${FCGI_PROGRAM_EXEC} -- ${SOCKET_OPTION} ${INET_OPTION} \
99 -P ${P} ${OPTIONS} -- ${FCGI_PROGRAM}
100 RETVAL=$?
101
102 # Stop on error. Don't want to spawn a mess!
103 [ "${RETVAL}" != "0" ] && break
104 done
105 eend ${RETVAL}
106 }
107
108 stop() {
109 local X RETVAL=0
110
111 ebegin "Stopping FastCGI application ${PROGNAME}"
112 for X in ${PIDFILE}-[0-9]*.pid ; do
113 start-stop-daemon --stop --pidfile ${X} || \
114 { RETVAL=$? && break ; }
115 done
116 eend ${RETVAL}
117 }

  ViewVC Help
Powered by ViewVC 1.1.20