Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-php/, app-eselect/eselect-php/files/
Date: Tue, 24 Nov 2015 20:17:05
Message-Id: 1448395920.a0709457d61898989510adfa26c4cb615f18165b.mjo@gentoo
1 commit: a0709457d61898989510adfa26c4cb615f18165b
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 24 20:11:36 2015 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 24 20:12:00 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0709457
7
8 app-eselect/eselect-php: new revision to test config before FPM start/reload.
9
10 Now that we have a configtest() command for the php-fpm daemon, we
11 should run it before attempting to reload the daemon. This prevents
12 the (working) daemon from crashing if the new config has a typo in it.
13
14 Performing the same check before start() avoids a five-second wait if
15 there is an error in the config.
16
17 Gentoo-Bug: 487642
18
19 Package-Manager: portage-2.2.20.1
20
21 ...-php-0.7.1-r6.ebuild => eselect-php-0.7.1-r7.ebuild} | 2 +-
22 .../files/{php-fpm.init-r3 => php-fpm.init-r4} | 17 ++++++++++++++---
23 2 files changed, 15 insertions(+), 4 deletions(-)
24
25 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
26 similarity index 95%
27 rename from app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild
28 rename to app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild
29 index cd21027..6937b4a 100644
30 --- a/app-eselect/eselect-php/eselect-php-0.7.1-r6.ebuild
31 +++ b/app-eselect/eselect-php/eselect-php-0.7.1-r7.ebuild
32 @@ -33,7 +33,7 @@ src_install() {
33 fi
34
35 if use fpm ; then
36 - newinitd "${FILESDIR}/php-fpm.init-r3" "php-fpm"
37 + newinitd "${FILESDIR}/php-fpm.init-r4" "php-fpm"
38 systemd_dotmpfilesd "${FILESDIR}/php-fpm.conf"
39 exeinto /usr/libexec
40 doexe "${FILESDIR}/php-fpm-launcher"
41
42 diff --git a/app-eselect/eselect-php/files/php-fpm.init-r3 b/app-eselect/eselect-php/files/php-fpm.init-r4
43 similarity index 67%
44 rename from app-eselect/eselect-php/files/php-fpm.init-r3
45 rename to app-eselect/eselect-php/files/php-fpm.init-r4
46 index a1b956e..6502ab9 100644
47 --- a/app-eselect/eselect-php/files/php-fpm.init-r3
48 +++ b/app-eselect/eselect-php/files/php-fpm.init-r4
49 @@ -6,7 +6,7 @@ extra_commands="configtest"
50 set_phpvars() {
51 PHPSLOT="${SVCNAME#php-fpm-}"
52 PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid"
53 - if [ ${PHPSLOT} = 'php-fpm' ] ; then
54 + if [ "${PHPSLOT}" = "php-fpm" ] ; then
55 PHPSLOT="$(eselect php show fpm)"
56 PHP_FPM_PID="/run/php-fpm.pid"
57 fi
58 @@ -16,6 +16,9 @@ set_phpvars() {
59 }
60
61 start() {
62 + # If configtest fails, we don't have to sit around for five
63 + # seconds waiting for a pid to show up.
64 + configtest || return $?
65 ebegin "Starting PHP FastCGI Process Manager"
66 set_phpvars
67 start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \
68 @@ -45,6 +48,7 @@ stop() {
69 }
70
71 reload() {
72 + configtest || return $?
73 ebegin "Reloading PHP FastCGI Process Manager"
74 set_phpvars
75 [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}")
76 @@ -54,6 +58,13 @@ reload() {
77 configtest() {
78 ebegin "Testing PHP FastCGI Process Manager configuration"
79 set_phpvars
80 - "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test
81 - eend $?
82 + # Hide the "test is successful" message (which goes to stderr) if
83 + # the test passed, but show the entire output if the test failed
84 + # because it may contain hints about the problem.
85 + OUTPUT=$( "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test 2>&1 )
86 +
87 + # Save this so `echo` doesn't clobber it.
88 + local exit_code=$?
89 + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2
90 + eend $exit_code
91 }