Skip to content

Commit

Permalink
Only restart nginx when elasticsearch is switched
Browse files Browse the repository at this point in the history
  • Loading branch information
mischabraam committed Jun 24, 2024
1 parent 60c94eb commit 2e653ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cli/ValetPlus/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand All @@ -139,14 +140,15 @@ 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.
$this->stop($currentVersion);
}

$this->install($version, $tld);
return true;
}


Expand Down
9 changes: 6 additions & 3 deletions cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -629,8 +630,10 @@
break;
}

PhpFpm::restart();
Nginx::restart();
if ($restart) {
PhpFpm::restart();
Nginx::restart();
}
})
->descriptions(
'Enable/disable/switch Elasticsearch. ' .
Expand Down

0 comments on commit 2e653ba

Please sign in to comment.