diff options
author | 2016-07-26 17:02:40 -0400 | |
---|---|---|
committer | 2016-07-26 17:26:27 -0400 | |
commit | f98dfac61c8076d7cf8ab6a9ab574b047dd07952 (patch) | |
tree | d85d90ac1e8d86246f9bd7073fa8b3b8584d8628 | |
parent | Bump to v0.9.1 in configure.ac. (diff) | |
download | eselect-php-f98dfac61c8076d7cf8ab6a9ab574b047dd07952.tar.gz eselect-php-f98dfac61c8076d7cf8ab6a9ab574b047dd07952.tar.bz2 eselect-php-f98dfac61c8076d7cf8ab6a9ab574b047dd07952.zip |
Add OpenRC init and conf files.
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | doc/php-fpm.example.conf | 8 | ||||
-rw-r--r-- | doc/php-fpm.example.init | 71 |
3 files changed, 81 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index d9220bd..719ced1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,8 @@ eselectdir = $(datadir)/eselect/modules nodist_eselect_DATA = $(srcdir)/src/php.eselect -# Without this, the conf input file doesn't wind up in the tarball. -EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in +# Without EXTRA_DIST, these files don't wind up in the tarball. +EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in doc/*.* if APACHE2 # Without these set, we won't try to install the conf file. diff --git a/doc/php-fpm.example.conf b/doc/php-fpm.example.conf new file mode 100644 index 0000000..b3efdbf --- /dev/null +++ b/doc/php-fpm.example.conf @@ -0,0 +1,8 @@ +# The OpenRC conf.d file that accompanies the php-fpm init script. +# Not to be confused with the php-fpm.conf file that ships with +# PHP itself. + +# Set the umask of the FPM process to the given (octal) value. This is +# passed directly to start-stop-daemon. If not specified, the system +# default will be used. +#PHP_FPM_UMASK=0002 diff --git a/doc/php-fpm.example.init b/doc/php-fpm.example.init new file mode 100644 index 0000000..6369e9f --- /dev/null +++ b/doc/php-fpm.example.init @@ -0,0 +1,71 @@ +#!/sbin/openrc-run + +extra_started_commands="reload" +extra_commands="configtest" + +set_phpvars() { + PHPSLOT="${SVCNAME#php-fpm-}" + PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid" + if [ "${PHPSLOT}" = "php-fpm" ] ; then + PHPSLOT="$(eselect php show fpm)" + PHP_FPM_PID="/run/php-fpm.pid" + fi + + PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf" + PHP_FPM_BIN="/usr/lib/${PHPSLOT}/bin/php-fpm" +} + +start() { + # If configtest fails, we don't have to sit around for five + # seconds waiting for a pid to show up. + configtest || return $? + ebegin "Starting PHP FastCGI Process Manager" + set_phpvars + start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \ + --exec "${PHP_FPM_BIN}" \ + ${PHP_FPM_UMASK:+--umask ${PHP_FPM_UMASK}} \ + -- \ + --fpm-config "${PHP_FPM_CONF}" \ + --pid "${PHP_FPM_PID}" + local i=0 + local timeout=5 + while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do + sleep 1 + i=$(($i + 1)) + done + + [ $timeout -gt $i ] + eend $? +} + +stop() { + ebegin "Stopping PHP FastCGI Process Manager" + set_phpvars + start-stop-daemon --signal QUIT \ + --stop \ + --exec "${PHP_FPM_BIN}" \ + --pidfile "${PHP_FPM_PID}" + eend $? +} + +reload() { + configtest || return $? + ebegin "Reloading PHP FastCGI Process Manager" + set_phpvars + [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}") + eend $? +} + +configtest() { + ebegin "Testing PHP FastCGI Process Manager configuration" + set_phpvars + # Hide the "test is successful" message (which goes to stderr) if + # the test passed, but show the entire output if the test failed + # because it may contain hints about the problem. + OUTPUT=$( "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test 2>&1 ) + + # Save this so `echo` doesn't clobber it. + local exit_code=$? + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2 + eend $exit_code +} |