Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eselect-php:master commit in: doc/, /
Date: Tue, 26 Jul 2016 21:37:56
Message-Id: 1469568387.f98dfac61c8076d7cf8ab6a9ab574b047dd07952.mjo@gentoo
1 commit: f98dfac61c8076d7cf8ab6a9ab574b047dd07952
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 26 21:02:40 2016 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 21:26:27 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=f98dfac6
7
8 Add OpenRC init and conf files.
9
10 Makefile.am | 4 +--
11 doc/php-fpm.example.conf | 8 ++++++
12 doc/php-fpm.example.init | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
13 3 files changed, 81 insertions(+), 2 deletions(-)
14
15 diff --git a/Makefile.am b/Makefile.am
16 index d9220bd..719ced1 100644
17 --- a/Makefile.am
18 +++ b/Makefile.am
19 @@ -1,8 +1,8 @@
20 eselectdir = $(datadir)/eselect/modules
21 nodist_eselect_DATA = $(srcdir)/src/php.eselect
22
23 -# Without this, the conf input file doesn't wind up in the tarball.
24 -EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in
25 +# Without EXTRA_DIST, these files don't wind up in the tarball.
26 +EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in doc/*.*
27
28 if APACHE2
29 # Without these set, we won't try to install the conf file.
30
31 diff --git a/doc/php-fpm.example.conf b/doc/php-fpm.example.conf
32 new file mode 100644
33 index 0000000..b3efdbf
34 --- /dev/null
35 +++ b/doc/php-fpm.example.conf
36 @@ -0,0 +1,8 @@
37 +# The OpenRC conf.d file that accompanies the php-fpm init script.
38 +# Not to be confused with the php-fpm.conf file that ships with
39 +# PHP itself.
40 +
41 +# Set the umask of the FPM process to the given (octal) value. This is
42 +# passed directly to start-stop-daemon. If not specified, the system
43 +# default will be used.
44 +#PHP_FPM_UMASK=0002
45
46 diff --git a/doc/php-fpm.example.init b/doc/php-fpm.example.init
47 new file mode 100644
48 index 0000000..6369e9f
49 --- /dev/null
50 +++ b/doc/php-fpm.example.init
51 @@ -0,0 +1,71 @@
52 +#!/sbin/openrc-run
53 +
54 +extra_started_commands="reload"
55 +extra_commands="configtest"
56 +
57 +set_phpvars() {
58 + PHPSLOT="${SVCNAME#php-fpm-}"
59 + PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid"
60 + if [ "${PHPSLOT}" = "php-fpm" ] ; then
61 + PHPSLOT="$(eselect php show fpm)"
62 + PHP_FPM_PID="/run/php-fpm.pid"
63 + fi
64 +
65 + PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf"
66 + PHP_FPM_BIN="/usr/lib/${PHPSLOT}/bin/php-fpm"
67 +}
68 +
69 +start() {
70 + # If configtest fails, we don't have to sit around for five
71 + # seconds waiting for a pid to show up.
72 + configtest || return $?
73 + ebegin "Starting PHP FastCGI Process Manager"
74 + set_phpvars
75 + start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \
76 + --exec "${PHP_FPM_BIN}" \
77 + ${PHP_FPM_UMASK:+--umask ${PHP_FPM_UMASK}} \
78 + -- \
79 + --fpm-config "${PHP_FPM_CONF}" \
80 + --pid "${PHP_FPM_PID}"
81 + local i=0
82 + local timeout=5
83 + while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do
84 + sleep 1
85 + i=$(($i + 1))
86 + done
87 +
88 + [ $timeout -gt $i ]
89 + eend $?
90 +}
91 +
92 +stop() {
93 + ebegin "Stopping PHP FastCGI Process Manager"
94 + set_phpvars
95 + start-stop-daemon --signal QUIT \
96 + --stop \
97 + --exec "${PHP_FPM_BIN}" \
98 + --pidfile "${PHP_FPM_PID}"
99 + eend $?
100 +}
101 +
102 +reload() {
103 + configtest || return $?
104 + ebegin "Reloading PHP FastCGI Process Manager"
105 + set_phpvars
106 + [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}")
107 + eend $?
108 +}
109 +
110 +configtest() {
111 + ebegin "Testing PHP FastCGI Process Manager configuration"
112 + set_phpvars
113 + # Hide the "test is successful" message (which goes to stderr) if
114 + # the test passed, but show the entire output if the test failed
115 + # because it may contain hints about the problem.
116 + OUTPUT=$( "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test 2>&1 )
117 +
118 + # Save this so `echo` doesn't clobber it.
119 + local exit_code=$?
120 + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2
121 + eend $exit_code
122 +}