Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1583fad

Browse files
committed
add option to force web server startup
The `server:start` command will report an error message when a lock file does exist. However, this means that you cannot restart the web server process if the previously running process terminated accidentally or if it was terminated by the user without executing the `server:stop` command (e.g. by using the system's `kill` command or the task manager). This commit adds a `--force` option that makes it possible to launch the web server process even if a lock file does exist.
1 parent 03e96d2 commit 1583fad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function configure()
3737
new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'),
3838
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
3939
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
40+
new InputOption('force', 'f', InputOption::VALUE_NONE, 'Force web server startup'),
4041
))
4142
->setName('server:start')
4243
->setDescription('Starts PHP built-in web server in the background')
@@ -110,8 +111,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
110111
$address = $address.':'.$input->getOption('port');
111112
}
112113

113-
if ($this->isOtherServerProcessRunning($address)) {
114+
if (!$input->getOption('force') && $this->isOtherServerProcessRunning($address)) {
114115
$output->writeln(sprintf('<error>A process is already listening on http://%s.</error>', $address));
116+
$output->writeln(sprintf('<error>Use the --force option if the server process terminated unexpectedly to start a new web server process.</error>'));
115117

116118
return 1;
117119
}

0 commit comments

Comments
 (0)