Hora en output
This commit is contained in:
@ -21,8 +21,22 @@ class BaseLoop extends Console\Command\Command
|
|||||||
|
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$output->writeln("Running Loop...");
|
$this->write($output, 'Running loop...');
|
||||||
|
|
||||||
|
$this->waitNextMinute($output);
|
||||||
|
|
||||||
|
$this->write($output, 'Starting loop...');
|
||||||
|
while (true) {
|
||||||
|
$commands = $this->scheduleService->getPending();
|
||||||
|
foreach ($commands as $command) {
|
||||||
|
$this->runCommand($input, $output, $command);
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
protected function waitNextMinute(Console\Output\OutputInterface $output): void
|
||||||
|
{
|
||||||
// wait for next minute
|
// wait for next minute
|
||||||
$now = new DateTimeImmutable();
|
$now = new DateTimeImmutable();
|
||||||
$nextMinute = new DateTimeImmutable($now->format('Y-m-d H:i:00'));
|
$nextMinute = new DateTimeImmutable($now->format('Y-m-d H:i:00'));
|
||||||
@ -32,16 +46,6 @@ class BaseLoop extends Console\Command\Command
|
|||||||
$output->writeln("Waiting {$diff} seconds...");
|
$output->writeln("Waiting {$diff} seconds...");
|
||||||
sleep($diff);
|
sleep($diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('Starting loop...');
|
|
||||||
while (true) {
|
|
||||||
$commands = $this->scheduleService->getPending();
|
|
||||||
foreach ($commands as $command) {
|
|
||||||
$this->runCommand($input, $output, $command);
|
|
||||||
sleep(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
}
|
||||||
protected function runCommand(Console\Input\InputInterface $input, Console\Output\OutputInterface $output, string $commandName): int
|
protected function runCommand(Console\Input\InputInterface $input, Console\Output\OutputInterface $output, string $commandName): int
|
||||||
{
|
{
|
||||||
@ -61,4 +65,9 @@ class BaseLoop extends Console\Command\Command
|
|||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected function write(Console\Output\OutputInterface $output, string $message): void
|
||||||
|
{
|
||||||
|
$now = new DateTimeImmutable();
|
||||||
|
$output->writeln("[{$now->format('Y-m-d H:i:s e')}] {$message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,8 @@ class Queue extends Command
|
|||||||
{
|
{
|
||||||
$this->logger->debug("Running {$this->getName()}");
|
$this->logger->debug("Running {$this->getName()}");
|
||||||
$io = new Console\Style\SymfonyStyle($input, $output);
|
$io = new Console\Style\SymfonyStyle($input, $output);
|
||||||
$io->title("Running Queue...");
|
$now = new DateTimeImmutable();
|
||||||
|
$io->title("[{$now->format('Y-m-d H:i:s e')}] Running Queue...");
|
||||||
|
|
||||||
$uri = '/api/queue/run';
|
$uri = '/api/queue/run';
|
||||||
$output->writeln("GET {$uri}");
|
$output->writeln("GET {$uri}");
|
||||||
|
Reference in New Issue
Block a user