mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 16:10:08 +01:00
Merge pull request #1422 from drbyte/stopdnsmasq
Add "valet stop dnsmasq" option
This commit is contained in:
@@ -52,6 +52,14 @@ public function uninstall(): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the dnsmasq service.
|
||||
*/
|
||||
public function stop(): void
|
||||
{
|
||||
$this->brew->stopService(['dnsmasq']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell Homebrew to restart dnsmasq.
|
||||
*/
|
||||
|
||||
@@ -112,6 +112,7 @@ public function restart(string $phpVersion = null): void
|
||||
*/
|
||||
public function stop(): void
|
||||
{
|
||||
info('Stopping phpfpm...');
|
||||
call_user_func_array(
|
||||
[$this->brew, 'stopService'],
|
||||
Brew::SUPPORTED_PHP_VERSIONS
|
||||
@@ -138,6 +139,7 @@ public function fpmConfigPath(string $phpVersion = null): string
|
||||
*/
|
||||
public function stopRunning(): void
|
||||
{
|
||||
info('Stopping phpfpm...');
|
||||
$this->brew->stopService(
|
||||
$this->brew->getAllRunningServices()
|
||||
->filter(function ($service) {
|
||||
|
||||
14
cli/app.php
14
cli/app.php
@@ -506,7 +506,13 @@ function (ConsoleCommandEvent $event) {
|
||||
PhpFpm::stopRunning();
|
||||
Nginx::stop();
|
||||
|
||||
return info('Valet services have been stopped.');
|
||||
return info('Valet core services have been stopped. To also stop dnsmasq, run: valet stop dnsmasq');
|
||||
case 'all':
|
||||
PhpFpm::stopRunning();
|
||||
Nginx::stop();
|
||||
Dnsmasq::stop();
|
||||
|
||||
return info('All Valet services have been stopped.');
|
||||
case 'nginx':
|
||||
Nginx::stop();
|
||||
|
||||
@@ -515,10 +521,14 @@ function (ConsoleCommandEvent $event) {
|
||||
PhpFpm::stopRunning();
|
||||
|
||||
return info('PHP has been stopped.');
|
||||
case 'dnsmasq':
|
||||
Dnsmasq::stop();
|
||||
|
||||
return info('dnsmasq has been stopped.');
|
||||
}
|
||||
|
||||
return warning(sprintf('Invalid valet service name [%s]', $service));
|
||||
})->descriptions('Stop the Valet services');
|
||||
})->descriptions('Stop the core Valet services, or all services by specifying "all".');
|
||||
|
||||
/**
|
||||
* Uninstall Valet entirely. Requires --force to actually remove; otherwise manual instructions are displayed.
|
||||
|
||||
@@ -759,7 +759,7 @@ public function test_stop_command()
|
||||
$tester->run(['command' => 'stop']);
|
||||
$tester->assertCommandIsSuccessful();
|
||||
|
||||
$this->assertStringContainsString('Valet services have been stopped.', $tester->getDisplay());
|
||||
$this->assertStringContainsString('Valet core services have been stopped.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_command_stops_nginx()
|
||||
@@ -792,6 +792,21 @@ public function test_stop_command_stops_php()
|
||||
$this->assertStringContainsString('PHP has been stopped', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_all_command_stops_dnsmasq()
|
||||
{
|
||||
[$app, $tester] = $this->appAndTester();
|
||||
|
||||
$phpfpm = Mockery::mock(DnsMasq::class);
|
||||
$phpfpm->shouldReceive('stop');
|
||||
|
||||
swap(DnsMasq::class, $phpfpm);
|
||||
|
||||
$tester->run(['command' => 'stop', 'service' => 'dnsmasq']);
|
||||
$tester->assertCommandIsSuccessful();
|
||||
|
||||
$this->assertStringContainsString('dnsmasq has been stopped', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function test_stop_command_handles_bad_services()
|
||||
{
|
||||
[$app, $tester] = $this->appAndTester();
|
||||
|
||||
Reference in New Issue
Block a user