Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
freestream committed Aug 5, 2020
1 parent 93d709d commit ea0e390
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 19 deletions.
12 changes: 11 additions & 1 deletion Console/Command/Labour.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
} catch (\ParseError $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
} catch (\Error $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
}

return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
Expand Down
51 changes: 42 additions & 9 deletions Console/Command/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process as SymfonyProcess;
use Symfony\Component\Process\Exception\ProcessFailedException;

use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -263,20 +263,54 @@ protected function execute(InputInterface $input, OutputInterface $output)
continue;
}

$process = $this->_getProcess($labour);
try {
$process = $this->_getProcess($labour);

$process->start();
$this->dbHelper->updateLabourField($labour, 'pid', (string) $process->getPid());

$this->dbHelper->updateLabourField($labour, 'pid', (string) $process->getPid());
$process->start();

$processes[] = $process;
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}

$processes[] = $process;
} catch (\Exception $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");

$labour->reschedule();
} catch (\ParseError $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");

$labour->reschedule();
} catch (\Error $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");

$labour->reschedule();
}
}
}
} catch (\Exception $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
} catch (\ParseError $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
} catch (\Error $e) {
$this->logger->critical($e);
$msg = $e->getMessage();
$output->writeln("<error>$msg</error>");
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}

return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
Expand Down Expand Up @@ -330,19 +364,18 @@ protected function _getProcess(LabourModel $labour) : Process

$labourCmd->configure();

$php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php';
$php = $_SERVER['_'];
$magentoBinary = $php . " -f {$this->rootPath}/bin/magento";
$labourCmdName = $labourCmd->getName();
$arguments = $labour->getId();

$process = (new Process([
$magentoBinary,
$php,
$labourCmdName,
$arguments,
]))
->setTimeout($this->arrHelper->get('timeout', $config))
->setLabour($labour)
->disableOutput();
->setLabour($labour);

return $process;
}
Expand Down
16 changes: 8 additions & 8 deletions Model/Labour.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,21 @@ public function execute() : void
$this->_execute();
$this->_afterExecute();
} catch (RescheduleException $e) {
$this->reschedule();

$this->logger->critical($e);
} catch (\Exception $e) {
$this->reschedule();

$this->logger->critical($e);
} catch (\ParseError $e) {
$this->reschedule();

} catch (\Exception $e) {
$this->logger->critical($e);
} catch (\Error $e) {

$this->reschedule();
} catch (\ParseError $e) {
$this->logger->critical($e);

$this->reschedule();
} catch (\Error $e) {
$this->logger->critical($e);

$this->reschedule();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Server/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Process
*
* @var Labour
*/
private $labor;
private $labour;

/**
* Set Labour instance
Expand Down

0 comments on commit ea0e390

Please sign in to comment.