-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebServerBundle] added a way to dump current status host/port/address when getting the status #22316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WebServerBundle] added a way to dump current status host/port/address when getting the status #22316
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ protected function configure() | |
->setName('server:status') | ||
->setDefinition(array( | ||
new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), | ||
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'The value to display (one of port, host, or address)'), | ||
)) | ||
->setDescription('Outputs the status of the local web server for the given address') | ||
; | ||
|
@@ -47,10 +48,29 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
{ | ||
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); | ||
$server = new WebServer(); | ||
if ($server->isRunning($input->getOption('pidfile'))) { | ||
$io->success(sprintf('Web server still listening on http://%s', $server->getAddress($input->getOption('pidfile')))); | ||
if ($filter = $input->getOption('filter')) { | ||
if ($server->isRunning($input->getOption('pidfile'))) { | ||
list($host, $port) = explode(':', $address = $server->getAddress($input->getOption('pidfile'))); | ||
if ('address' === $filter) { | ||
$output->write($address); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. input comes from the pidfile. If you mess up with it, then you are on your own anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note it can also be messed up by some formatter implementation. But fair enough.. what are the odds anyway :) |
||
} elseif ('host' === $filter) { | ||
$output->write($host); | ||
} elseif ('port' === $filter) { | ||
$output->write($port); | ||
} else { | ||
throw new \InvalidArgumentException(sprintf('"%s" is not a valid filter.', $filter)); | ||
} | ||
} else { | ||
return 1; | ||
} | ||
} else { | ||
$io->warning('No web server is listening.'); | ||
if ($server->isRunning($input->getOption('pidfile'))) { | ||
$io->success(sprintf('Web server still listening on http://%s', $server->getAddress($input->getOption('pidfile')))); | ||
} else { | ||
$io->warning('No web server is listening.'); | ||
|
||
return 1; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like
--value | --get | --get-value
?