From 579d324cc25bfe454b1486e8bbc89e9a41c41f79 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Fri, 22 Oct 2021 14:12:15 -0400 Subject: Save PHP_SLOT for reuse on stop Update the php-fpm script to allow the starting slot to be saved. This can then be used by the stop process to track the correct pidfile of what was started. Avoids errors when upgrading the unslotted script from one slot to another. eselect value will change and OpenRC is confused on what to stop as we give it the wrong PID location Signed-off-by: Brian Evans --- openrc/init.d/php-fpm.in.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openrc/init.d/php-fpm.in.in b/openrc/init.d/php-fpm.in.in index 2eaa2c3..3e67e3c 100644 --- a/openrc/init.d/php-fpm.in.in +++ b/openrc/init.d/php-fpm.in.in @@ -15,9 +15,15 @@ # slot php7.1 eselected, but also a php-fpm-php7.1 init script. Should # they manage the same instance? I think so... # + PHP_SLOT="${SVCNAME#php-fpm-}" if [ "${PHP_SLOT}" = "php-fpm" ] ; then - PHP_SLOT="$(eselect php show fpm)" + # Getting the saved slot allows for clean stops when upgrading to a new slot + # This will initially be empty on start and fall through to the default + PHP_SLOT="$(service_get_value PHP_SLOT)" + if [ -z "${PHP_SLOT}" ]; then + PHP_SLOT="$(eselect php show fpm)" + fi fi PHP_FPM_CONF="@SYSCONFDIR@/php/fpm-${PHP_SLOT}/php-fpm.conf" @@ -59,6 +65,7 @@ start_pre() { if [ "${RC_CMD}" != "restart" ] ; then configtest || return $? fi + service_set_value PHP_SLOT "${PHP_SLOT}" } stop_pre() { -- cgit v1.2.3-65-gdbad