|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MS\Sentry\Monitor\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
10
|
|
|
use Symfony\Component\Process\ProcessBuilder; |
|
11
|
|
|
|
|
12
|
|
|
class RunCommand extends Command |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @inheritdoc |
|
16
|
|
|
*/ |
|
17
|
|
|
protected function configure() |
|
18
|
|
|
{ |
|
19
|
|
|
$this |
|
20
|
|
|
->setName('run') |
|
21
|
|
|
->setDescription('run sentry monitor server') |
|
22
|
|
|
->addArgument('address', InputArgument::OPTIONAL, 'Address:port', 'localhost:8006') |
|
23
|
|
|
; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param InputInterface $input |
|
28
|
|
|
* @param OutputInterface $output |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
33
|
|
|
{ |
|
34
|
|
|
$io = new SymfonyStyle($input, $output); |
|
35
|
|
|
$io->title('Start and run sentry monitor'); |
|
36
|
|
|
|
|
37
|
|
|
$address = $input->getArgument('address'); |
|
38
|
|
|
$webPath = __DIR__ . '/../../web'; |
|
39
|
|
|
|
|
40
|
|
|
$processBuilder = new ProcessBuilder([PHP_BINARY, '-S', $address, $webPath . '/index.php']); |
|
41
|
|
|
$processBuilder |
|
42
|
|
|
->setWorkingDirectory($webPath . '/scripts') |
|
43
|
|
|
->setTimeout(null); |
|
44
|
|
|
|
|
45
|
|
|
$io->success(sprintf('Server running on "%s"', $address)); |
|
46
|
|
|
$io->comment('Quit the server with CONTROL-C.'); |
|
47
|
|
|
|
|
48
|
|
|
$process = $processBuilder->getProcess(); |
|
49
|
|
|
$process->run(); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|