From 1583fadbe95836b4d25db49cf141e34eb028927a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 28 Jun 2015 16:53:41 +0200 Subject: [PATCH] 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. --- .../Bundle/FrameworkBundle/Command/ServerStartCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php index d9eccc4d61..6300e9774a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerStartCommand.php @@ -37,6 +37,7 @@ class ServerStartCommand extends ServerCommand new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'), new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), + new InputOption('force', 'f', InputOption::VALUE_NONE, 'Force web server startup'), )) ->setName('server:start') ->setDescription('Starts PHP built-in web server in the background') @@ -110,8 +111,9 @@ EOF $address = $address.':'.$input->getOption('port'); } - if ($this->isOtherServerProcessRunning($address)) { + if (!$input->getOption('force') && $this->isOtherServerProcessRunning($address)) { $output->writeln(sprintf('A process is already listening on http://%s.', $address)); + $output->writeln(sprintf('Use the --force option if the server process terminated unexpectedly to start a new web server process.')); return 1; }