| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\Core\CommandLine;
- use ModulesGarden\ProxmoxAddon\Core\CommandLine\AbstractCommand;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputOption;
- class JobsLoop extends AbstractCommand
- {
- /**
- * Loop interval in seconds
- * @var int
- */
- protected $loopInterval = 5;
- /**
- * @var int
- */
- protected $maxChildren = 5;
- /**
- * @var int
- */
- protected $tasksPerChildren = 10;
- /**
- *
- */
- final protected function configure()
- {
- parent::configure();
- }
- /**
- *
- */
- final protected function setup()
- {
- $this->addOption('parent', InputOption::VALUE_OPTIONAL, 'Parent id', null);
- $this->addOption('id', InputOption::VALUE_OPTIONAL, 'Child id', null);
- }
- /**
- * Execute command in the loop
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- final protected function execute(InputInterface $input, OutputInterface $output)
- {
- $parent = $input->getOption('parent');
- $id = $input->getOption('id');
- $parentHypervior = new Hypervisor($this->getName());
- //Lock parent
- if (!$parent)
- {
- $parentHypervior->lock();
- }
- else
- {
- $parentHypervior->checkIfRunning();
- }
- if ($id)
- {
-
- }
- do
- {
- parent::process($input, $output, new SymfonyStyle($input, $output));
- sleep($this->loopInterval);
- }
- while (!$hypervisor->isStopped());
- }
- /**
- * @param $jobs[]
- */
- protected function processJobs($jobs)
- {
- foreach ($jobs as $job)
- {
-
- }
- }
- }
|