public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michael Orlitzky" <mjo@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-php/, app-eselect/eselect-php/files/
Date: Tue, 24 Nov 2015 20:16:57 +0000 (UTC)	[thread overview]
Message-ID: <1448395920.a0709457d61898989510adfa26c4cb615f18165b.mjo@gentoo> (raw)

commit:     a0709457d61898989510adfa26c4cb615f18165b
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 24 20:11:36 2015 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Tue Nov 24 20:12:00 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0709457

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

 ...-php-0.7.1-r6.ebuild => eselect-php-0.7.1-r7.ebuild} |  2 +-
 .../files/{php-fpm.init-r3 => php-fpm.init-r4}          | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild b/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild
similarity index 95%
rename from app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild
rename to app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild
index cd21027..6937b4a 100644
--- a/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild
+++ b/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild
@@ -33,7 +33,7 @@ src_install() {
 	fi
 
 	if use fpm ; then
-		newinitd "${FILESDIR}/php-fpm.init-r3" "php-fpm"
+		newinitd "${FILESDIR}/php-fpm.init-r4" "php-fpm"
 		systemd_dotmpfilesd "${FILESDIR}/php-fpm.conf"
 		exeinto /usr/libexec
 		doexe "${FILESDIR}/php-fpm-launcher"

diff --git a/app-eselect/eselect-php/files/php-fpm.init-r3 b/app-eselect/eselect-php/files/php-fpm.init-r4
similarity index 67%
rename from app-eselect/eselect-php/files/php-fpm.init-r3
rename to app-eselect/eselect-php/files/php-fpm.init-r4
index a1b956e..6502ab9 100644
--- a/app-eselect/eselect-php/files/php-fpm.init-r3
+++ b/app-eselect/eselect-php/files/php-fpm.init-r4
@@ -6,7 +6,7 @@ extra_commands="configtest"
 set_phpvars() {
 	PHPSLOT="${SVCNAME#php-fpm-}"
 	PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid"
-	if [ ${PHPSLOT} = 'php-fpm' ] ; then
+	if [ "${PHPSLOT}" = "php-fpm" ] ; then
 		PHPSLOT="$(eselect php show fpm)"
 		PHP_FPM_PID="/run/php-fpm.pid"
 	fi
@@ -16,6 +16,9 @@ set_phpvars() {
 }
 
 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}" \
@@ -45,6 +48,7 @@ stop() {
 }
 
 reload() {
+    configtest || return $?
     ebegin "Reloading PHP FastCGI Process Manager"
     set_phpvars
     [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}")
@@ -54,6 +58,13 @@ reload() {
 configtest() {
     ebegin "Testing PHP FastCGI Process Manager configuration"
     set_phpvars
-    "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test
-    eend $?
+    # 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
 }


             reply	other threads:[~2015-11-24 20:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 20:16 Michael Orlitzky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-10-16 14:44 [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-php/, app-eselect/eselect-php/files/ Michael Orlitzky
2015-11-23 18:15 Michael Orlitzky
2015-09-11 14:49 Manuel Rüger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448395920.a0709457d61898989510adfa26c4cb615f18165b.mjo@gentoo \
    --to=mjo@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox