From b76293809ce23179935506e94b1f51dd26595730 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 9 Jul 2017 21:26:06 +0200 Subject: [PATCH] Add a action acript to handle FPM restarts --- createlinks | 6 ++++ .../e-smith/events/actions/adjust-php-fpm-services | 37 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 root/etc/e-smith/events/actions/adjust-php-fpm-services diff --git a/createlinks b/createlinks index 1481168..45079b3 100644 --- a/createlinks +++ b/createlinks @@ -30,3 +30,9 @@ event_link("php-pool-dirs", "share-create", "90"); event_link("php-pool-dirs", "share-modify", "90"); event_link("php-pool-dirs", "share-modify-server", "90"); event_link("php-pool-dirs", "share-delete", "90"); + +event_link("adjust-php-fpm-services", "share-create", "98"); +event_link("adjust-php-fpm-services", "share-modify", "98"); +event_link("adjust-php-fpm-services", "share-modify-server", "98"); +event_link("adjust-php-fpm-services", "share-delete", "98"); +event_link("adjust-php-fpm-services", "webapps-update", "98"); diff --git a/root/etc/e-smith/events/actions/adjust-php-fpm-services b/root/etc/e-smith/events/actions/adjust-php-fpm-services new file mode 100644 index 0000000..2c7fa60 --- /dev/null +++ b/root/etc/e-smith/events/actions/adjust-php-fpm-services @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use esmith::ConfigDB; + +my $c = esmith::ConfigDB->open_ro || die "Couldn't open the configuration database\n"; +my @fpms = qw( + php-fpm + php56-php-fpm + php70-php-fpm + php71-php-fpm +); + +# We need to ensure every versions are stopped, and only then start them all again +# so if we move a pool from one version to another, we won't have a socket conflict + +foreach my $fpm (@fpms){ + my $service = $c->get($fpm); + esmith::util::serviceControl( + NAME => $fpm, + ACTION => 'stop', + BACKGROUND => 'false') + or die "Unable to stop $fpm\n"; +} + +foreach my $fpm (@fpms){ + my $service = $c->get($fpm); + if ($service && ($service->prop('status') || 'disabled') eq 'enabled'){ + esmith::util::serviceControl( + NAME => $fpm, + ACTION => 'start', + BACKGROUND => 'false') + or die "Unable to start $fpm\n"; + } +} +