1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Stop non-root homebrew services during restarts

This is intended to assist with avoiding having competing non-root instances of valet dependency services running due to userland use of brew CLI commands.

Now, when running `valet stop` or `valet restart` it will (silently) attempt to stop the non-root instance (ignoring any errors thrown), before stopping (and/or starting) the sudo/root instance which is normally used.

(Though obvious, I'll point out that this only applies to services Valet manages.)

Fixes #1057
This commit is contained in:
Chris Brown
2021-06-13 01:07:17 -04:00
parent 1aad1e072d
commit c549c1786a
2 changed files with 10 additions and 0 deletions

View File

@@ -197,7 +197,11 @@ function restartService($services)
if ($this->installed($service)) {
info("Restarting {$service}...");
// first we ensure that the service is not incorrectly running as non-root
$this->cli->quietly('brew services stop '.$service);
// stop the actual/correct sudo version
$this->cli->quietly('sudo brew services stop '.$service);
// start correctly as root
$this->cli->quietly('sudo brew services start '.$service);
}
}
@@ -216,6 +220,10 @@ function stopService($services)
if ($this->installed($service)) {
info("Stopping {$service}...");
// first we ensure that the service is not incorrectly running as non-root
$this->cli->quietly('brew services stop '.$service);
// stop the sudo version
$this->cli->quietly('sudo brew services stop '.$service);
}
}