From 8bc043065a8d7d50861cb2d2dcf15cf10297a7c4 Mon Sep 17 00:00:00 2001 From: Raul Ferriz Date: Sat, 4 Jan 2014 10:17:24 +0100 Subject: [PATCH 1/3] Check for option verbose instead of get it. This avoid crashing when called by daemonise command. --- PHPCI/Command/RunCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHPCI/Command/RunCommand.php b/PHPCI/Command/RunCommand.php index d635b8a2..8415fafe 100644 --- a/PHPCI/Command/RunCommand.php +++ b/PHPCI/Command/RunCommand.php @@ -68,7 +68,7 @@ class RunCommand extends Command // For verbose mode we want to output all informational and above // messages to the symphony output interface. - if ($input->getOption('verbose')) { + if ($input->hasOption('verbose')) { $this->logger->pushHandler( new OutputLogHandler($this->output, Logger::INFO) ); From 4b50b9eb77d53d8e25d48733e8a0a25e92d02222 Mon Sep 17 00:00:00 2001 From: Raul Ferriz Date: Sat, 4 Jan 2014 10:19:55 +0100 Subject: [PATCH 2/3] Fix daemonise crash. --- PHPCI/Command/DaemoniseCommand.php | 31 ++++++++++++++++++++++++++++-- daemonise | 4 +++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/PHPCI/Command/DaemoniseCommand.php b/PHPCI/Command/DaemoniseCommand.php index 3c490d75..999404d0 100644 --- a/PHPCI/Command/DaemoniseCommand.php +++ b/PHPCI/Command/DaemoniseCommand.php @@ -10,7 +10,9 @@ namespace PHPCI\Command; +use Monolog\Logger; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -27,6 +29,26 @@ use PHPCI\BuildFactory; */ class DaemoniseCommand extends Command { + /** + * @var Logger + */ + protected $logger; + + /** + * @var OutputInterface + */ + protected $output; + + /** + * @param \Monolog\Logger $logger + * @param string $name + */ + public function __construct(Logger $logger, $name = null) + { + parent::__construct($name); + $this->logger = $logger; + } + protected function configure() { $this @@ -43,14 +65,19 @@ class DaemoniseCommand extends Command $command = sprintf($cmd, getmypid(), PHPCI_DIR); exec($command); + $this->output = $output; $this->run = true; $this->sleep = 0; - $runner = new RunCommand; + $runner = new RunCommand($this->logger); + + $in = new ArgvInput(array()); while ($this->run) { + $buildCount = 0; + try { - $buildCount = $runner->execute($input, $output); + $buildCount = $runner->run($in, $output); } catch (\Exception $e) { var_dump($e); } diff --git a/daemonise b/daemonise index 0f1a6d1d..45751190 100755 --- a/daemonise +++ b/daemonise @@ -15,6 +15,8 @@ require('bootstrap.php'); use PHPCI\Command\DaemoniseCommand; use Symfony\Component\Console\Application; +$loggerConfig = \PHPCI\Helper\LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php"); + $application = new Application(); -$application->add(new DaemoniseCommand); +$application->add(new DaemoniseCommand($loggerConfig->getFor('DaemoniseCommand'))); $application->run(); From 1ac77fd26803939068212bd315d73fde50c0f98c Mon Sep 17 00:00:00 2001 From: Raul Ferriz Date: Sat, 4 Jan 2014 10:20:20 +0100 Subject: [PATCH 3/3] Removed unused use clauses. --- PHPCI/Command/DaemoniseCommand.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/PHPCI/Command/DaemoniseCommand.php b/PHPCI/Command/DaemoniseCommand.php index 999404d0..5d2f003a 100644 --- a/PHPCI/Command/DaemoniseCommand.php +++ b/PHPCI/Command/DaemoniseCommand.php @@ -17,9 +17,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use b8\Store\Factory; -use PHPCI\Builder; -use PHPCI\BuildFactory; /** * Daemon that loops and call the run-command.