-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to query the queue status and delete a job
- Loading branch information
1 parent
3538dd6
commit 887821d
Showing
6 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace OC\Core\Command\Background\Queue; | ||
|
||
use OC\Console\CommandLogger; | ||
use OCP\BackgroundJob\IJob; | ||
use OCP\ILogger; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\Table; | ||
use Symfony\Component\Console\Helper\TableHelper; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Delete extends Command { | ||
|
||
/** @var \OCP\BackgroundJob\IJobList */ | ||
private $jobList; | ||
|
||
public function __construct() { | ||
$this->jobList = \OC::$server->getJobList(); | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() { | ||
$this | ||
->setName("background:queue:delete") | ||
->setDescription("Delete a job from the queue") | ||
->addArgument('id', InputArgument::REQUIRED, 'id of the job to be deleted'); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$id = $input->getArgument('id'); | ||
|
||
$job = $this->jobList->getById($id); | ||
if (is_null($job)) { | ||
$output->writeln("Job with id <$id> is not known."); | ||
return; | ||
} | ||
|
||
$this->jobList->removeById($id); | ||
$output->writeln("Job has been deleted."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace OC\Core\Command\Background\Queue; | ||
|
||
use OC\Console\CommandLogger; | ||
use OCP\BackgroundJob\IJob; | ||
use OCP\ILogger; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\Table; | ||
use Symfony\Component\Console\Helper\TableHelper; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Status extends Command { | ||
|
||
/** @var \OCP\BackgroundJob\IJobList */ | ||
private $jobList; | ||
|
||
public function __construct() { | ||
$this->jobList = \OC::$server->getJobList(); | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() { | ||
$this | ||
->setName("background:queue:status") | ||
->setDescription("List queue status"); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
/** @var TableHelper $t */ | ||
$t = $this->getHelper('table'); | ||
$t->setHeaders(['Id', 'Job', 'Last run', 'Arguments']); | ||
$this->jobList->listJobs(function (IJob $job) use ($t) { | ||
$t->addRow([$job->getId(), get_class($job), date('c', $job->getLastRun()), $job->getArgument()]); | ||
}); | ||
$t->render($output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters