public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/eselect-php:master commit in: doc/, /
@ 2016-07-26 21:37 Michael Orlitzky
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Orlitzky @ 2016-07-26 21:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f98dfac61c8076d7cf8ab6a9ab574b047dd07952
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 21:02:40 2016 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Tue Jul 26 21:26:27 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=f98dfac6

Add OpenRC init and conf files.

 Makefile.am              |  4 +--
 doc/php-fpm.example.conf |  8 ++++++
 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
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/eselect-php:master commit in: doc/, /
@ 2017-07-19 14:11 Michael Orlitzky
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Orlitzky @ 2017-07-19 14:11 UTC (permalink / raw
  To: gentoo-commits

commit:     41fa94bb1977c31b3a280005585187d00df2424e
Author:     Michael Orlitzky <michael <AT> orlitzky <DOT> com>
AuthorDate: Wed Jul 19 14:02:44 2017 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Wed Jul 19 14:02:44 2017 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=41fa94bb

Rename the init script input file to facilitate the two-phase replacement.

We perform variable substitution twice in the main eselect script --
once through autotools, and the other manually in the resulting
Makefile. As a result, the script has a double "in.in" suffix. To make
substitution work the same way in the init script, this commit renames
it with an "in.in" suffix, and mentions it in configure.ac.

 configure.ac                                                | 2 +-
 doc/{php-fpm.example.init.in => php-fpm.example.init.in.in} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d642dbd..9f8b4eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,6 @@ AC_ARG_ENABLE(
 
 
 # List of output files.
-AC_CONFIG_FILES([Makefile src/php.eselect.in])
+AC_CONFIG_FILES([Makefile src/php.eselect.in doc/php-fpm.example.init.in])
 
 AC_OUTPUT

diff --git a/doc/php-fpm.example.init.in b/doc/php-fpm.example.init.in.in
similarity index 100%
rename from doc/php-fpm.example.init.in
rename to doc/php-fpm.example.init.in.in


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-19 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-19 14:11 [gentoo-commits] proj/eselect-php:master commit in: doc/, / Michael Orlitzky
  -- strict thread matches above, loose matches on Subject: below --
2016-07-26 21:37 Michael Orlitzky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox