Adding a debug mode to the worker so you can see what commands are being run.

This commit is contained in:
Dan Cryer 2016-04-27 14:56:52 +01:00
parent 5ead42a7c2
commit 21d5f4954f
No known key found for this signature in database
GPG key ID: 6030CBA5FE342813
3 changed files with 22 additions and 2 deletions

View file

@ -50,7 +50,8 @@ class WorkerCommand extends Command
{
$this
->setName('phpci:worker')
->setDescription('Runs the PHPCI build worker.');
->setDescription('Runs the PHPCI build worker.')
->addOption('debug', null, null, 'Run PHPCI in Debug Mode');
}
protected function execute(InputInterface $input, OutputInterface $output)
@ -65,6 +66,12 @@ class WorkerCommand extends Command
);
}
// Allow PHPCI to run in "debug mode"
if ($input->hasOption('debug') && $input->getOption('debug')) {
$output->writeln('<comment>Debug mode enabled.</comment>');
define('PHPCI_DEBUG_MODE', true);
}
$config = Config::getInstance()->get('phpci.worker', []);
if (empty($config['host']) || empty($config['queue'])) {

View file

@ -90,6 +90,10 @@ abstract class BaseCommandExecutor implements CommandExecutor
$pipes = array();
if (defined('PHPCI_DEBUG_MODE')) {
$this->logger->logDebug($command);
}
$process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);
if (is_resource($process)) {

View file

@ -67,7 +67,7 @@ class BuildLogger implements LoggerAwareInterface
}
}
/**
/**
* Add a success-coloured message to the log.
* @param string
*/
@ -98,6 +98,15 @@ class BuildLogger implements LoggerAwareInterface
);
}
/**
* Add a debug message to the log.
* @param string
*/
public function logDebug($message)
{
$this->log("\033[0;33m" . $message . "\033[0m");
}
/**
* Sets a logger instance on the object
*