hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
940 stars 560 forks source link

Better support for no-tty mode in the server command #3143

Open jorissteyn opened 7 years ago

jorissteyn commented 7 years ago

On master, there seems to be regression introduced in https://github.com/hechoendrupal/drupal-console/pull/3088. When running the server command in tty-mode, I expect lines such as:

[Tue Jan 31 09:58:08 2017] 127.0.0.1:37598 [200]: /user

But they do not show up anymore.

Furthermore, and perhaps this should be a separate issue in the issue tracker, I believe it is very valuable to support disabling tty-mode. With tty-mode, it is impossible to capture the output of the command. For example, when running the server command in the background on Travis CI, the output of behat will be cluttered with log messages of the server command.

I propose to add an option to disable tty-mode. In 1.x that could be implemented like this:

        if (
            (!$input->getOption('no-tty-mode')) &&
            ('\\' !== DIRECTORY_SEPARATOR) &&
            file_exists('/dev/tty') &&
            is_readable('/dev/tty')
        ) {
            $process->setTty('true');
            $process->run();
        } else {
            $process->setTimeout(null);
            $process->run(function ($type, $buffer) use ($io) {
                $io->write($buffer);
            });
        }

But the refactoring going on in master necessitates another approach. The basic idea will be the same: enable tty-mode, or disable tty-mode and write the output ourselves.

jmolivas commented 7 years ago

@jorissteyn you can also try server -vvv

jmolivas commented 7 years ago

@jorissteyn We can probably add something like that code you propose to the ShellProcess service https://github.com/hechoendrupal/drupal-console-core/blob/master/src/Utils/ShellProcess.php and update the server command to use that service.