Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions amp_conf/htdocs/admin/libraries/Console/Job.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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")));
Expand All @@ -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('<error>The command is already running in another process.</error>');
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;
}
Expand Down