1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Bluz PHP Team |
5
|
|
|
* @link https://github.com/bluzphp/bluzman |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Bluzman\Command\Server; |
9
|
|
|
|
10
|
|
|
use Bluzman\Input\InputOption; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
13
|
|
|
use Symfony\Component\Process\Process; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* StopCommand |
17
|
|
|
* |
18
|
|
|
* @package Bluzman\Command\Server |
19
|
|
|
* |
20
|
|
|
* @author Pavel Machekhin |
21
|
|
|
* @created 2013-06-17 14:47 |
22
|
|
|
*/ |
23
|
|
|
class StopCommand extends AbstractServerCommand |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Command configuration |
27
|
15 |
|
*/ |
28
|
|
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this |
31
|
15 |
|
// the name of the command (the part after "bin/bluzman") |
32
|
|
|
->setName('server:stop') |
33
|
15 |
|
// the short description shown while running "php bin/bluzman list" |
34
|
|
|
->setDescription('Stop a built-in PHP server') |
35
|
|
|
// the full command description shown when running the command with |
36
|
15 |
|
// the "--help" option |
37
|
|
|
->setHelp('This command allows you to stop built-in PHP server') |
38
|
15 |
|
; |
39
|
15 |
|
$this->addOption('host', null, InputOption::VALUE_OPTIONAL, 'IP address of the server', '0.0.0.0'); |
40
|
15 |
|
$this->addOption('port', null, InputOption::VALUE_OPTIONAL, 'Port of the server', '8000'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param InputInterface $input |
45
|
|
|
* @param OutputInterface $output |
46
|
|
|
* @return int |
47
|
|
|
*/ |
48
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
49
|
|
|
{ |
50
|
|
|
$this->info('Running "server:stop" command'); |
51
|
|
|
|
52
|
|
|
$host = $input->getOption('host'); |
53
|
|
|
$port = $input->getOption('port'); |
54
|
|
|
|
55
|
|
|
$pid = $this->getProcessId($host, $port) ?: false; |
56
|
|
|
|
57
|
|
|
if (empty($pid)) { |
58
|
|
|
$this->comment('Server is not running'); |
59
|
|
|
return 1; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$process = Process::fromShellCommandline("kill -9 $pid"); |
63
|
|
|
$process->run(); |
64
|
|
|
|
65
|
|
|
$this->write("Server <info>$host:$port</info> stopped"); |
66
|
|
|
return 0; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths