diff options
author | Thilo Bangert <bangert@gentoo.org> | 2009-04-01 10:12:17 +0000 |
---|---|---|
committer | Thilo Bangert <bangert@gentoo.org> | 2009-04-01 10:12:17 +0000 |
commit | 2f49e5c441d2031ccfae5ddf364c2355f3f0140c (patch) | |
tree | 34d00edcd5a933c8b1b1ee374df9021c0f9f8f59 /www-servers/spawn-fcgi/files | |
parent | Automated update of use.local.desc (diff) | |
download | gentoo-2-2f49e5c441d2031ccfae5ddf364c2355f3f0140c.tar.gz gentoo-2-2f49e5c441d2031ccfae5ddf364c2355f3f0140c.tar.bz2 gentoo-2-2f49e5c441d2031ccfae5ddf364c2355f3f0140c.zip |
initial commit - init script adapted from bug #149467 - thanks everybody
(Portage version: 2.2_rc26/cvs/Linux i686)
Diffstat (limited to 'www-servers/spawn-fcgi/files')
-rw-r--r-- | www-servers/spawn-fcgi/files/spawn-fcgi.confd | 54 | ||||
-rw-r--r-- | www-servers/spawn-fcgi/files/spawn-fcgi.initd | 94 |
2 files changed, 148 insertions, 0 deletions
diff --git a/www-servers/spawn-fcgi/files/spawn-fcgi.confd b/www-servers/spawn-fcgi/files/spawn-fcgi.confd new file mode 100644 index 000000000000..78f72e2bd0b3 --- /dev/null +++ b/www-servers/spawn-fcgi/files/spawn-fcgi.confd @@ -0,0 +1,54 @@ +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.confd,v 1.1 2009/04/01 10:12:17 bangert Exp $ + +# DO NOT MODIFY THIS FILE DIRECTLY! CREATE A COPY AND MODIFY THAT INSTEAD! + +# One of the following options must be enabled. The filename specified by +# FCGI_SOCKET will be suffixed with a number for each child process, for +# example, fcgi.socket-1. The port specified by FCGI_PORT is the port used +# by the first child process. If this is set to 1234 then subsequent child +# processes will use 1235, 1236, etc. +# +FCGI_SOCKET= +FCGI_PORT=1234 + +# When using FCGI_PORT, connections will only be accepted from the following +# address. The default is 127.0.0.1. Use 0.0.0.0 to bind to all addresses. +# +FCGI_ADDRESS=127.0.0.1 + +# The path to your FastCGI application. These sometimes carry the .fcgi +# extension but not always. For PHP, you should usually point this to +# /usr/bin/php-cgi. +# +FCGI_PROGRAM=/path/to/application.fcgi + +# The number of child processes to spawn. The default is 1. For PHP +# applications, set this to 1 and use PHP_FCGI_CHILDREN instead. +# +FCGI_CHILDREN=1 + +# If you want to run your application inside a chroot then specify the +# directory here. Leave this blank otherwise. +# +FCGI_CHROOT= + +# The user and group to run your application as. If you do not specify these, +# the application will be run as root:root. +# +FCGI_USER= +FCGI_GROUP= + +# If your application requires additional environment variables, you need to +# allow them here. Only the variables specified here, plus a few others +# mentioned in the init script are passed to the application. +# +ALLOWED_ENV="" + +# PHP ONLY :: These two options are specific to PHP. The first is the number +# of child processes to spawn. The second is the number of requests to be +# served by a single PHP process before it is restarted. +# +PHP_FCGI_CHILDREN=5 +PHP_FCGI_MAX_REQUESTS=500 diff --git a/www-servers/spawn-fcgi/files/spawn-fcgi.initd b/www-servers/spawn-fcgi/files/spawn-fcgi.initd new file mode 100644 index 000000000000..999a31e689ba --- /dev/null +++ b/www-servers/spawn-fcgi/files/spawn-fcgi.initd @@ -0,0 +1,94 @@ +#!/sbin/runscript +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/www-servers/spawn-fcgi/files/spawn-fcgi.initd,v 1.1 2009/04/01 10:12:17 bangert Exp $ + +PROGNAME=${SVCNAME/spawn\-fcgi./} +SPAWNFCGI=/usr/bin/spawn-fcgi +PIDPATH=/var/run/spawn-fcgi +PIDFILE=${PIDPATH}/${PROGNAME} + +depend() { + need net +} + +start() { + if [[ "${SVCNAME}" == "spawn-fcgi" ]]; then + eerror "You are not supposed to run this script directly. Create a symlink" + eerror "for the FastCGI application you want to run as well as a copy of the" + eerror "configuration file and modify it appropriately like so..." + eerror + eerror " ln -s spawn-fcgi /etc/init.d/spawn-fcgi.trac" + eerror " cp /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.trac" + eerror " `basename "${EDITOR}"` /etc/conf.d/spawn-fcgi.trac" + eerror + return 1 + fi + + if [[ ! -z "${FCGI_SOCKET}" ]] && [[ ! -z "${FCGI_PORT}" ]]; then + eerror "Only one of both must be defined:" + eerror " FCGI_SOCKET=${FCGI_SOCKET}" + eerror " FCGI_PORT=${FCGI_PORT}" + return 1 + fi + + local X E OPTIONS SOCKET_OPTION PORT_OPTION RETVAL + + if [[ -z "${FCGI_ADDRESS}" ]]; then + FCGI_ADDRESS=127.0.0.1 + fi + + if [[ -z "${FCGI_CHILDREN}" ]]; then + FCGI_CHILDREN=1 + fi + + if [[ -n "${PHP_FCGI_CHILDREN}" ]]; then + OPTIONS="${OPTIONS} -C ${PHP_FCGI_CHILDREN}" + fi + + if [[ -n "${FCGI_CHROOT}" ]]; then + OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}" + fi + + if [[ -n "${FCGI_USER}" ]] && [[ "${FCGI_USER}" != "root" ]]; then + OPTIONS="${OPTIONS} -u ${FCGI_USER}" + fi + + if [[ -n "${FCGI_GROUP}" ]] && [[ "${FCGI_GROUP}" != "root" ]]; then + OPTIONS="${OPTIONS} -g ${FCGI_GROUP}" + fi + + ALLOWED_ENV="$ALLOWED_ENV USER GROUPS PHP_FCGI_MAX_REQUESTS RAILS_ENV TRAC_ENV_PARENT_DIR TRAC_ENV" + unset E + + for i in ${ALLOWED_ENV}; do + [[ -n "${!i}" ]] && E="${E} -e ${i}=${!i}" + done + + ebegin "Starting FastCGI application ${PROGNAME}" + for X in `seq 1 ${FCGI_CHILDREN}`; do + local P + P=${PIDFILE}-${X}.pid + [[ -n "${FCGI_SOCKET}" ]] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}" + [[ -n "${FCGI_PORT}" ]] && PORT_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))" + + start-stop-daemon --start --pidfile ${P} ${E} --exec ${SPAWNFCGI} -- \ + ${SOCKET_OPTION} ${PORT_OPTION} -f ${FCGI_PROGRAM} -P ${P} ${OPTIONS} + RETVAL=$? + + # Stop on error. Don't want to spawn a mess! + [[ "${RETVAL}" != "0" ]] && break + done + eend ${RETVAL} +} + +stop() { + local X RETVAL=0 + + ebegin "Stopping FastCGI application ${PROGNAME}" + for X in ${PIDFILE}-[0-9]*.pid ; do + start-stop-daemon --stop --pidfile ${X} || \ + { RETVAL=$? && break ; } + done + eend ${RETVAL} +} |