diff --git a/amp_conf/htdocs/admin/libraries/Console/Job.class.php b/amp_conf/htdocs/admin/libraries/Console/Job.class.php index 6f1e8fa2f7..77cbd621dc 100644 --- a/amp_conf/htdocs/admin/libraries/Console/Job.class.php +++ b/amp_conf/htdocs/admin/libraries/Console/Job.class.php @@ -39,11 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output){ $this->output = $output; $this->input = $input; - if (!$this->lock()) { - $output->writeln('The command is already running in another process.'); - return 0; - } - if($input->getOption('force')) { $this->force = true; } @@ -58,22 +53,6 @@ protected function execute(InputInterface $input, OutputInterface $output){ return 0; } - if($input->getOption('disable')) { - $this->runJobs($this->registerTasks($this->findAllJobs([$input->getOption('run')]))); - return 0; - } - - if($input->hasParameterOption('--run') && is_null($input->getOption('run'))) { - //run all - $this->runJobs($this->registerTasks($this->findAllJobs())); - return 0; - } - - if($input->getOption('run')) { - $this->runJobs($this->registerTasks($this->findAllJobs([$input->getOption('run')]))); - return 0; - } - if($input->getOption('list')) { $table = new Table($output); $table->setHeaders(array(_('ID'),_('Module'),_('Job'),_('Cron'),_('Next Run'),_('Action'),_("Enabled"))); @@ -94,6 +73,24 @@ protected function execute(InputInterface $input, OutputInterface $output){ return 0; } + // Acquire lock only for --run to prevent concurrent job execution. + // Non-destructive operations (--list, --enable, --disable, help) + // do not need mutual exclusion and should not be blocked. + if($input->hasParameterOption('--run')) { + if (!$this->lock()) { + $output->writeln('The command is already running in another process.'); + return 1; + } + + if(is_null($input->getOption('run'))) { + //run all + $this->runJobs($this->registerTasks($this->findAllJobs())); + } else { + $this->runJobs($this->registerTasks($this->findAllJobs([$input->getOption('run')]))); + } + return 0; + } + $this->outputHelp($input,$output); return 0; }