| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Cron;
- use ModulesGarden\ProxmoxAddon\Core\CommandLine\CommandLoop;
- use ModulesGarden\ProxmoxAddon\Core\CommandLine\Hypervisor;
- use ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Console\Style\SymfonyStyle;
- class QueueLoop extends CommandLoop
- {
- /**
- * Command name
- * @var string
- */
- protected $name = 'queue-loop';
- /**
- * Command description
- * @var string
- */
- protected $description = 'Run module queue loop';
- /**
- * Command help text
- * @var string
- */
- protected $help = 'Just run that command to start all queued tasks!';
- protected function process(InputInterface $input, OutputInterface $output, SymfonyStyle $io)
- {
- $queue = new \ModulesGarden\ProxmoxAddon\Core\Queue\Queue();
- $queue->setCallBefore(function (Job $job) use ($input,$io)
- {
- $io->writeln("Running {$job->job}");
- (new Hypervisor($this->getName(), $input->getOptions()))
- ->ping();
- });
- $queue->process();
- }
- }
|