This commit is contained in:
2023-06-16 21:44:35 -04:00
parent b553ac403e
commit adad8cea81
18 changed files with 360 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace ProVM\Command;
use DateTimeImmutable;
use DateInterval;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: 'watch',
hidden: false
)]
class Watch extends Command
{
public function __construct(protected string $period, ?string $name = 'watch')
{
parent::__construct($name);
}
public function execute(InputInterface $input, OutputInterface $output): int
{
$period = new DateInterval($this->period);
$current = new DateTimeImmutable();
while(true) {
$now = new DateTimeImmutable();
if ($now->diff($current) === $period) {
$this->runUpdate();
$current = $now;
}
}
return Command::SUCCESS;
}
protected function runUpdate(): void
{
$command = '/app/bin/console update';
shell_exec($command);
}
}