summaryrefslogtreecommitdiff
path: root/www-servers/spawn-fcgi/files
diff options
context:
space:
mode:
Diffstat (limited to 'www-servers/spawn-fcgi/files')
-rw-r--r--www-servers/spawn-fcgi/files/spawn-fcgi.confd73
-rw-r--r--www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1116
-rw-r--r--www-servers/spawn-fcgi/files/spawn-fcgi.initd-r2116
3 files changed, 305 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..3e7f103a8fe2
--- /dev/null
+++ b/www-servers/spawn-fcgi/files/spawn-fcgi.confd
@@ -0,0 +1,73 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# DO NOT MODIFY THIS FILE DIRECTLY! CREATE A COPY AND MODIFY THAT INSTEAD!
+
+# The FCGI process can be made available through a filesystem socket or
+# through a inet socket. One and only one of the two types must be choosen.
+# Default is the inet socket.
+
+# The filename specified by
+# FCGI_SOCKET will be suffixed with a number for each child process, for
+# example, fcgi.socket-1.
+# Leave empty to use an IP socket (default). See below. Enabling this,
+# disables the IP socket.
+#
+FCGI_SOCKET=
+
+# 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 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_PORT=1234
+
+# 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=/usr/bin/php-cgi
+FCGI_PROGRAM=
+
+# The number of child processes to spawn. The default is 1.
+#
+FCGI_CHILDREN=1
+
+# If you want to run your application inside a chroot then specify the
+# directory here. Leave this blank otherwise.
+#
+FCGI_CHROOT=
+
+# If you want to run your application from a specific directiory specify
+# it here. Leave this blank otherwise.
+#
+FCGI_CHDIR=
+
+# 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=
+
+# Additional options you might want to pass to spawn-fcgi
+#
+#FCGI_EXTRA_OPTIONS=
+
+# If your application requires additional environment variables, you may
+# specify them here. See PHP example below.
+#
+ALLOWED_ENV="PATH"
+
+# 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
+#
+# For this to work you would set
+# ALLOWED_ENV="PATH PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS"
diff --git a/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1 b/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1
new file mode 100644
index 000000000000..74879c2eb6fc
--- /dev/null
+++ b/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r1
@@ -0,0 +1,116 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+PROGNAME=${SVCNAME#*.}
+SPAWNFCGI=/usr/bin/spawn-fcgi
+PIDPATH=/var/run/spawn-fcgi
+PIDFILE=${PIDPATH}/${PROGNAME}
+
+depend() {
+ need net
+}
+
+start() {
+ local X E OPTIONS i RETVAL FCGI_PROGRAM_EXEC
+ FCGI_PROGRAM_EXEC=$(echo ${FCGI_PROGRAM} | awk "{print \$1}")
+
+ 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 the two may be defined:"
+ eerror " FCGI_SOCKET=${FCGI_SOCKET}"
+ eerror " FCGI_PORT=${FCGI_PORT}"
+ return 1
+ fi
+
+ if [ -z "${FCGI_PROGRAM}" ]; then
+ eerror "You need to specify which \$FCGI_PROGRAM"
+ eerror "you want to start."
+ eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
+ return 1
+ fi
+
+ if [ ! -x "${FCGI_PROGRAM_EXEC}" ]; then
+ eerror "The file specified as \$FCGI_PROGRAM"
+ eerror "does not exist or is not executable."
+ eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
+ return 1
+ fi
+
+ if [ -z "${FCGI_ADDRESS}" ]; then
+ FCGI_ADDRESS=127.0.0.1
+ fi
+
+ if [ -z "${FCGI_CHILDREN}" ]; then
+ FCGI_CHILDREN=1
+ fi
+
+ if [ -n "${FCGI_CHROOT}" ]; then
+ OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
+ fi
+
+ if [ -n "${FCGI_DIR}" ]; then
+ OPTIONS="${OPTIONS} -d ${FCGI_DIR}"
+ 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
+
+ if [ -n "${FCGI_EXTRA_OPTIONS}" ]; then
+ OPTIONS="${OPTIONS} ${FCGI_EXTRA_OPTIONS}"
+ fi
+
+ unset E
+ for i in ${ALLOWED_ENV}; do
+ local j
+ eval j=$(echo \$"$i")
+ [ -n "${j}" ] && E="${E} ${i}=${j}"
+ done
+
+ ebegin "Starting FastCGI application ${PROGNAME}"
+ checkpath -q -d -m 700 /var/run/spawn-fcgi
+ X=0
+ while [ $X -lt ${FCGI_CHILDREN} ]; do
+ X=$(($X+1))
+ local P SOCKET_OPTION INET_OPTION
+ P=${PIDFILE}-${X}.pid
+ [ -n "${FCGI_SOCKET}" ] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
+ [ -n "${FCGI_PORT}" ] && INET_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
+
+ env -i ${E} /sbin/start-stop-daemon --start --pidfile ${P} --exec ${SPAWNFCGI} \
+ --name ${FCGI_PROGRAM_EXEC} -- ${SOCKET_OPTION} ${INET_OPTION} \
+ -P ${P} ${OPTIONS} -- ${FCGI_PROGRAM}
+ 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}
+}
diff --git a/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r2 b/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r2
new file mode 100644
index 000000000000..e7941a125a58
--- /dev/null
+++ b/www-servers/spawn-fcgi/files/spawn-fcgi.initd-r2
@@ -0,0 +1,116 @@
+#!/sbin/openrc-run
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+PROGNAME=${SVCNAME#*.}
+SPAWNFCGI=/usr/bin/spawn-fcgi
+PIDPATH=/run/spawn-fcgi
+PIDFILE=${PIDPATH}/${PROGNAME}
+
+depend() {
+ need net
+}
+
+start() {
+ local X E OPTIONS i RETVAL FCGI_PROGRAM_EXEC
+ FCGI_PROGRAM_EXEC=$(echo ${FCGI_PROGRAM} | awk "{print \$1}")
+
+ 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 the two may be defined:"
+ eerror " FCGI_SOCKET=${FCGI_SOCKET}"
+ eerror " FCGI_PORT=${FCGI_PORT}"
+ return 1
+ fi
+
+ if [ -z "${FCGI_PROGRAM}" ]; then
+ eerror "You need to specify which \$FCGI_PROGRAM"
+ eerror "you want to start."
+ eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
+ return 1
+ fi
+
+ if [ ! -x "${FCGI_PROGRAM_EXEC}" ]; then
+ eerror "The file specified as \$FCGI_PROGRAM"
+ eerror "does not exist or is not executable."
+ eerror "Please adjust /etc/conf.d/spawn-fcgi.${PROGNAME}"
+ return 1
+ fi
+
+ if [ -z "${FCGI_ADDRESS}" ]; then
+ FCGI_ADDRESS=127.0.0.1
+ fi
+
+ if [ -z "${FCGI_CHILDREN}" ]; then
+ FCGI_CHILDREN=1
+ fi
+
+ if [ -n "${FCGI_CHROOT}" ]; then
+ OPTIONS="${OPTIONS} -c ${FCGI_CHROOT}"
+ fi
+
+ if [ -n "${FCGI_DIR}" ]; then
+ OPTIONS="${OPTIONS} -d ${FCGI_DIR}"
+ 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
+
+ if [ -n "${FCGI_EXTRA_OPTIONS}" ]; then
+ OPTIONS="${OPTIONS} ${FCGI_EXTRA_OPTIONS}"
+ fi
+
+ unset E
+ for i in ${ALLOWED_ENV}; do
+ local j
+ eval j=$(echo \$"$i")
+ [ -n "${j}" ] && E="${E} ${i}=${j}"
+ done
+
+ ebegin "Starting FastCGI application ${PROGNAME}"
+ checkpath -q -d -m 700 /run/spawn-fcgi
+ X=0
+ while [ $X -lt ${FCGI_CHILDREN} ]; do
+ X=$(($X+1))
+ local P SOCKET_OPTION INET_OPTION
+ P=${PIDFILE}-${X}.pid
+ [ -n "${FCGI_SOCKET}" ] && SOCKET_OPTION="-s ${FCGI_SOCKET}-${X}"
+ [ -n "${FCGI_PORT}" ] && INET_OPTION="-a ${FCGI_ADDRESS} -p $((${FCGI_PORT} + ${X} - 1))"
+
+ env -i ${E} /sbin/start-stop-daemon --start --pidfile ${P} --exec ${SPAWNFCGI} \
+ --name ${FCGI_PROGRAM_EXEC} -- ${SOCKET_OPTION} ${INET_OPTION} \
+ -P ${P} ${OPTIONS} -- ${FCGI_PROGRAM}
+ 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}
+}