From a0709457d61898989510adfa26c4cb615f18165b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 24 Nov 2015 15:11:36 -0500 Subject: app-eselect/eselect-php: new revision to test config before FPM start/reload. Now that we have a configtest() command for the php-fpm daemon, we should run it before attempting to reload the daemon. This prevents the (working) daemon from crashing if the new config has a typo in it. Performing the same check before start() avoids a five-second wait if there is an error in the config. Gentoo-Bug: 487642 Package-Manager: portage-2.2.20.1 --- .../eselect-php/eselect-php-0.7.1-r6.ebuild | 41 ------------- .../eselect-php/eselect-php-0.7.1-r7.ebuild | 41 +++++++++++++ app-eselect/eselect-php/files/php-fpm.init-r3 | 59 ------------------ app-eselect/eselect-php/files/php-fpm.init-r4 | 70 ++++++++++++++++++++++ 4 files changed, 111 insertions(+), 100 deletions(-) delete mode 100644 app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild create mode 100644 app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild delete mode 100644 app-eselect/eselect-php/files/php-fpm.init-r3 create mode 100644 app-eselect/eselect-php/files/php-fpm.init-r4 (limited to 'app-eselect') diff --git a/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild b/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild deleted file mode 100644 index cd210279e6b..00000000000 --- a/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 1999-2015 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -EAPI=5 - -inherit depend.apache systemd - -DESCRIPTION="PHP eselect module" -HOMEPAGE="https://www.gentoo.org" -SRC_URI="https://dev.gentoo.org/~olemarkus/eselect-php/eselect-php-${PV}.bz2" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" -IUSE="fpm apache2" - -# The "DirectoryIndex" line in 70_mod_php5.conf requires mod_dir. -RDEPEND="app-admin/eselect - apache2? ( www-servers/apache[apache2_modules_dir] )" -S="${WORKDIR}" - -want_apache - -src_install() { - insinto /usr/share/eselect/modules/ - newins "eselect-php-${PV}" php.eselect - - if use apache2 ; then - insinto "${APACHE_MODULES_CONFDIR#${EPREFIX}}" - newins "${FILESDIR}/70_mod_php5.conf-apache2-r1" \ - "70_mod_php5.conf" - fi - - if use fpm ; then - newinitd "${FILESDIR}/php-fpm.init-r3" "php-fpm" - systemd_dotmpfilesd "${FILESDIR}/php-fpm.conf" - exeinto /usr/libexec - doexe "${FILESDIR}/php-fpm-launcher" - fi -} diff --git a/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild b/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild new file mode 100644 index 00000000000..6937b4ad008 --- /dev/null +++ b/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 + +inherit depend.apache systemd + +DESCRIPTION="PHP eselect module" +HOMEPAGE="https://www.gentoo.org" +SRC_URI="https://dev.gentoo.org/~olemarkus/eselect-php/eselect-php-${PV}.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" +IUSE="fpm apache2" + +# The "DirectoryIndex" line in 70_mod_php5.conf requires mod_dir. +RDEPEND="app-admin/eselect + apache2? ( www-servers/apache[apache2_modules_dir] )" +S="${WORKDIR}" + +want_apache + +src_install() { + insinto /usr/share/eselect/modules/ + newins "eselect-php-${PV}" php.eselect + + if use apache2 ; then + insinto "${APACHE_MODULES_CONFDIR#${EPREFIX}}" + newins "${FILESDIR}/70_mod_php5.conf-apache2-r1" \ + "70_mod_php5.conf" + fi + + if use fpm ; then + newinitd "${FILESDIR}/php-fpm.init-r4" "php-fpm" + systemd_dotmpfilesd "${FILESDIR}/php-fpm.conf" + exeinto /usr/libexec + doexe "${FILESDIR}/php-fpm-launcher" + fi +} diff --git a/app-eselect/eselect-php/files/php-fpm.init-r3 b/app-eselect/eselect-php/files/php-fpm.init-r3 deleted file mode 100644 index a1b956ea78e..00000000000 --- a/app-eselect/eselect-php/files/php-fpm.init-r3 +++ /dev/null @@ -1,59 +0,0 @@ -#!/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() { - ebegin "Starting PHP FastCGI Process Manager" - set_phpvars - start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \ - --exec "${PHP_FPM_BIN}" \ - -- \ - --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() { - 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 - "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test - eend $? -} diff --git a/app-eselect/eselect-php/files/php-fpm.init-r4 b/app-eselect/eselect-php/files/php-fpm.init-r4 new file mode 100644 index 00000000000..6502ab9b7d0 --- /dev/null +++ b/app-eselect/eselect-php/files/php-fpm.init-r4 @@ -0,0 +1,70 @@ +#!/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}" \ + -- \ + --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 +} -- cgit v1.2.1