Gentoo Archives: gentoo-commits

From: "Thilo Bangert (bangert)" <bangert@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in www-servers/spawn-fcgi/files: spawn-fcgi.initd spawn-fcgi.confd
Date: Wed, 01 Apr 2009 10:12:19
Message-Id: E1LoxQf-00021A-FK@stork.gentoo.org
1 bangert 09/04/01 10:12:17
2
3 Added: spawn-fcgi.initd spawn-fcgi.confd
4 Log:
5 initial commit - init script adapted from bug #149467 - thanks everybody
6 (Portage version: 2.2_rc26/cvs/Linux i686)
7
8 Revision Changes Path
9 1.1 www-servers/spawn-fcgi/files/spawn-fcgi.initd
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd?rev=1.1&content-type=text/plain
13
14 Index: spawn-fcgi.initd
15 ===================================================================
16 #!/sbin/runscript
17 # Copyright 1999-2009 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19 # $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.1 2009/04/01 10:12:17 bangert Exp $
20
21 PROGNAME=${SVCNAME/spawn\-fcgi./}
22 SPAWNFCGI=/usr/bin/spawn-fcgi
23 PIDPATH=/var/run/spawn-fcgi
24 PIDFILE=${PIDPATH}/${PROGNAME}
25
26 depend() {
27 need net
28 }
29
30 start() {
31 if [[ "${SVCNAME}" == "spawn-fcgi" ]]; then
32 eerror "You are not supposed to run this script directly. Create a symlink"
33 eerror "for the FastCGI application you want to run as well as a copy of the"
34 eerror "configuration file and modify it appropriately like so..."
35 eerror
36 eerror " ln -s spawn-fcgi /etc/init.d/spawn-fcgi.trac"
37 eerror " cp /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.trac"
38 eerror " `basename "${EDITOR}"` /etc/conf.d/spawn-fcgi.trac"
39 eerror
40 return 1
41 fi
42
43 if [[ ! -z "${FCGI_SOCKET}" ]] && [[ ! -z "${FCGI_PORT}" ]]; then
44 eerror "Only one of both must be defined:"
45 eerror " FCGI_SOCKET=${FCGI_SOCKET}"
46 eerror " FCGI_PORT=${FCGI_PORT}"
47 return 1
48 fi
49
50 local X E OPTIONS SOCKET_OPTION PORT_OPTION RETVAL
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 "${PHP_FCGI_CHILDREN}" ]]; then
61 OPTIONS="${OPTIONS} -C ${PHP_FCGI_CHILDREN}"
62 fi
63
64 if [[ -n "${FCGI_CHROOT}" ]]; then
65 OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
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 ALLOWED_ENV="$ALLOWED_ENV USER GROUPS PHP_FCGI_MAX_REQUESTS RAILS_ENV TRAC_ENV_PARENT_DIR TRAC_ENV"
77 unset E
78
79 for i in ${ALLOWED_ENV}; do
80 [[ -n "${!i}" ]] && E="${E} -e ${i}=${!i}"
81 done
82
83 ebegin "Starting FastCGI application ${PROGNAME}"
84 for X in `seq 1 ${FCGI_CHILDREN}`; do
85 local P
86 P=${PIDFILE}-${X}.pid
87 [[ -n "${FCGI_SOCKET}" ]] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
88 [[ -n "${FCGI_PORT}" ]] && PORT_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
89
90 start-stop-daemon --start --pidfile ${P} ${E} --exec ${SPAWNFCGI} -- \
91 ${SOCKET_OPTION} ${PORT_OPTION} -f ${FCGI_PROGRAM} -P ${P} ${OPTIONS}
92 RETVAL=$?
93
94 # Stop on error. Don't want to spawn a mess!
95 [[ "${RETVAL}" != "0" ]] && break
96 done
97 eend ${RETVAL}
98 }
99
100 stop() {
101 local X RETVAL=0
102
103 ebegin "Stopping FastCGI application ${PROGNAME}"
104 for X in ${PIDFILE}-[0-9]*.pid ; do
105 start-stop-daemon --stop --pidfile ${X} || \
106 { RETVAL=$? && break ; }
107 done
108 eend ${RETVAL}
109 }
110
111
112
113 1.1 www-servers/spawn-fcgi/files/spawn-fcgi.confd
114
115 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.confd?rev=1.1&view=markup
116 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.confd?rev=1.1&content-type=text/plain
117
118 Index: spawn-fcgi.confd
119 ===================================================================
120 # Copyright 1999-2009 Gentoo Foundation
121 # Distributed under the terms of the GNU General Public License v2
122 # $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.confd,v 1.1 2009/04/01 10:12:17 bangert Exp $
123
124 # DO NOT MODIFY THIS FILE DIRECTLY! CREATE A COPY AND MODIFY THAT INSTEAD!
125
126 # One of the following options must be enabled. The filename specified by
127 # FCGI_SOCKET will be suffixed with a number for each child process, for
128 # example, fcgi.socket-1. The port specified by FCGI_PORT is the port used
129 # by the first child process. If this is set to 1234 then subsequent child
130 # processes will use 1235, 1236, etc.
131 #
132 FCGI_SOCKET=
133 FCGI_PORT=1234
134
135 # When using FCGI_PORT, connections will only be accepted from the following
136 # address. The default is 127.0.0.1. Use 0.0.0.0 to bind to all addresses.
137 #
138 FCGI_ADDRESS=127.0.0.1
139
140 # The path to your FastCGI application. These sometimes carry the .fcgi
141 # extension but not always. For PHP, you should usually point this to
142 # /usr/bin/php-cgi.
143 #
144 FCGI_PROGRAM=/path/to/application.fcgi
145
146 # The number of child processes to spawn. The default is 1. For PHP
147 # applications, set this to 1 and use PHP_FCGI_CHILDREN instead.
148 #
149 FCGI_CHILDREN=1
150
151 # If you want to run your application inside a chroot then specify the
152 # directory here. Leave this blank otherwise.
153 #
154 FCGI_CHROOT=
155
156 # The user and group to run your application as. If you do not specify these,
157 # the application will be run as root:root.
158 #
159 FCGI_USER=
160 FCGI_GROUP=
161
162 # If your application requires additional environment variables, you need to
163 # allow them here. Only the variables specified here, plus a few others
164 # mentioned in the init script are passed to the application.
165 #
166 ALLOWED_ENV=""
167
168 # PHP ONLY :: These two options are specific to PHP. The first is the number
169 # of child processes to spawn. The second is the number of requests to be
170 # served by a single PHP process before it is restarted.
171 #
172 PHP_FCGI_CHILDREN=5
173 PHP_FCGI_MAX_REQUESTS=500