JobsLoop.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxVps\Core\CommandLine;
  3. use Symfony\Component\Console\Input\InputOption;
  4. class JobsLoop extends AbstractCommand
  5. {
  6. /**
  7. * Loop interval in seconds
  8. * @var int
  9. */
  10. protected $loopInterval = 5;
  11. /**
  12. * @var int
  13. */
  14. protected $maxChildren = 5;
  15. /**
  16. * @var int
  17. */
  18. protected $tasksPerChildren = 10;
  19. /**
  20. *
  21. */
  22. final protected function configure()
  23. {
  24. parent::configure();
  25. }
  26. /**
  27. *
  28. */
  29. final protected function setup()
  30. {
  31. $this->addOption('parent', InputOption::VALUE_OPTIONAL, 'Parent id', null);
  32. $this->addOption('id', InputOption::VALUE_OPTIONAL, 'Child id', null);
  33. }
  34. /**
  35. * Execute command in the loop
  36. * @param InputInterface $input
  37. * @param OutputInterface $output
  38. */
  39. final protected function execute(InputInterface $input, OutputInterface $output)
  40. {
  41. $parent = $input->getOption('parent');
  42. $id = $input->getOption('id');
  43. $parentHypervior = new Hypervisor($this->getName());
  44. //Lock parent
  45. if(!$parent)
  46. {
  47. $parentHypervior->lock();
  48. }
  49. else
  50. {
  51. $parentHypervior->checkIfRunning();
  52. }
  53. if($id)
  54. {
  55. }
  56. do
  57. {
  58. parent::process($input, $output, new SymfonyStyle($input, $output));
  59. sleep($this->loopInterval);
  60. }
  61. while(!$hypervisor->isStopped());
  62. }
  63. /**
  64. * @param $jobs[]
  65. */
  66. protected function processJobs($jobs)
  67. {
  68. foreach($jobs as $job)
  69. {
  70. }
  71. }
  72. }