Fixed cron worker in fails. Issue #68.
This commit is contained in:
parent
2af20dc00c
commit
dd9aecd3ff
|
@ -13,7 +13,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use b8\Store\Factory;
|
||||
use PHPCensor\Builder;
|
||||
use PHPCensor\BuilderException;
|
||||
use PHPCensor\BuildFactory;
|
||||
use PHPCensor\Model\Build;
|
||||
|
||||
|
@ -83,9 +82,9 @@ class RunCommand extends Command
|
|||
$this->logger->pushProcessor(new LoggedBuildContextTidier());
|
||||
$this->logger->addInfo('Finding builds to process');
|
||||
|
||||
/** @var BuildStore $store */
|
||||
$store = Factory::getStore('Build');
|
||||
$result = $store->getByStatus(Build::STATUS_PENDING, $this->maxBuilds);
|
||||
/** @var BuildStore $buildStore */
|
||||
$buildStore = Factory::getStore('Build');
|
||||
$result = $buildStore->getByStatus(Build::STATUS_PENDING, $this->maxBuilds);
|
||||
|
||||
$this->logger->addInfo(sprintf('Found %d builds', count($result['items'])));
|
||||
|
||||
|
@ -111,26 +110,14 @@ class RunCommand extends Command
|
|||
try {
|
||||
$builder = new Builder($build, $this->logger);
|
||||
$builder->execute();
|
||||
|
||||
} catch (BuilderException $ex) {
|
||||
$this->logger->addError($ex->getMessage());
|
||||
switch($ex->getCode()) {
|
||||
case BuilderException::FAIL_START:
|
||||
// non fatal
|
||||
break;
|
||||
default:
|
||||
$build->setStatus(Build::STATUS_FAILED);
|
||||
$build->setFinished(new \DateTime());
|
||||
$build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
|
||||
$store->save($build);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->addError($ex->getMessage());
|
||||
|
||||
$build->setStatus(Build::STATUS_FAILED);
|
||||
$build->setFinished(new \DateTime());
|
||||
$build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
|
||||
$store->save($build);
|
||||
$buildStore->save($build);
|
||||
$build->sendStatusPostback();
|
||||
}
|
||||
|
||||
// After execution we no longer want to record the information
|
||||
|
|
|
@ -7,7 +7,6 @@ use Monolog\Logger;
|
|||
use Pheanstalk\Job;
|
||||
use Pheanstalk\Pheanstalk;
|
||||
use PHPCensor\Builder;
|
||||
use PHPCensor\BuilderException;
|
||||
use PHPCensor\BuildFactory;
|
||||
use PHPCensor\Logging\BuildDBLogHandler;
|
||||
use PHPCensor\Model\Build;
|
||||
|
|
Loading…
Reference in a new issue