From 2e653ba3757c175b16b179590099ef61928c77f3 Mon Sep 17 00:00:00 2001 From: Mischa Braam Date: Mon, 24 Jun 2024 11:00:43 +0200 Subject: [PATCH] Only restart nginx when elasticsearch is switched --- cli/ValetPlus/Elasticsearch.php | 4 +++- cli/valet.php | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cli/ValetPlus/Elasticsearch.php b/cli/ValetPlus/Elasticsearch.php index 2af5caf0..b5c142c2 100644 --- a/cli/ValetPlus/Elasticsearch.php +++ b/cli/ValetPlus/Elasticsearch.php @@ -122,6 +122,7 @@ public function getCurrentVersion(): ?string * * @param string $version * @param string $tld + * @return bool */ public function useVersion($version = self::ES_DEFAULT_VERSION, $tld = 'test') { @@ -139,7 +140,7 @@ public function useVersion($version = self::ES_DEFAULT_VERSION, $tld = 'test') if ($version === $currentVersion) { info('Already on this version'); - return; + return false; } if ($currentVersion) { // Stop current version. @@ -147,6 +148,7 @@ public function useVersion($version = self::ES_DEFAULT_VERSION, $tld = 'test') } $this->install($version, $tld); + return true; } diff --git a/cli/valet.php b/cli/valet.php index ba35d1ad..6943f249 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -607,10 +607,11 @@ throw new RuntimeException(sprintf('Not enough arguments (missing: "mode"). Available modes: %s', implode(', ', $modes))); } + $restart = true; switch ($mode) { case 'install': case 'use': - Elasticsearch::useVersion($targetVersion, Configuration::read()['tld']); + $restart = Elasticsearch::useVersion($targetVersion, Configuration::read()['tld']); break; case 'on': @@ -629,8 +630,10 @@ break; } - PhpFpm::restart(); - Nginx::restart(); + if ($restart) { + PhpFpm::restart(); + Nginx::restart(); + } }) ->descriptions( 'Enable/disable/switch Elasticsearch. ' .