Rename commands

This commit is contained in:
Romain Neutron
2013-10-29 12:09:44 +01:00
parent 169b251968
commit c0ab4944f9
9 changed files with 28 additions and 20 deletions

View File

@@ -30,13 +30,15 @@ use Alchemy\Phrasea\Command\Plugin\RemovePlugin;
use Alchemy\Phrasea\Command\CheckConfig; use Alchemy\Phrasea\Command\CheckConfig;
use Alchemy\Phrasea\Command\Setup\XSendFileMappingGenerator; use Alchemy\Phrasea\Command\Setup\XSendFileMappingGenerator;
use Alchemy\Phrasea\Command\Setup\XSendFileConfigurationDumper; use Alchemy\Phrasea\Command\Setup\XSendFileConfigurationDumper;
use Alchemy\Phrasea\Command\Task\SchedulerStart; use Alchemy\Phrasea\Command\Task\SchedulerResumeTasks;
use Alchemy\Phrasea\Command\Task\SchedulerState; use Alchemy\Phrasea\Command\Task\SchedulerState;
use Alchemy\Phrasea\Command\Task\SchedulerStop; use Alchemy\Phrasea\Command\Task\SchedulerPauseTasks;
use Alchemy\Phrasea\Command\Task\SchedulerRun;
use Alchemy\Phrasea\Command\Task\TaskList; use Alchemy\Phrasea\Command\Task\TaskList;
use Alchemy\Phrasea\Command\Task\TaskRun; use Alchemy\Phrasea\Command\Task\TaskRun;
use Alchemy\Phrasea\Command\Task\TaskStart;
use Alchemy\Phrasea\Command\Task\TaskStop;
use Alchemy\Phrasea\Command\Task\TaskState; use Alchemy\Phrasea\Command\Task\TaskState;
use Alchemy\Phrasea\Command\Task\TaskManagerCommand;
require_once __DIR__ . '/../lib/autoload.php'; require_once __DIR__ . '/../lib/autoload.php';
@@ -83,11 +85,13 @@ $cli->command(new \module_console_systemExport('system:export'));
$cli->command(new TaskRun()); $cli->command(new TaskRun());
$cli->command(new TaskList()); $cli->command(new TaskList());
$cli->command(new TaskState()); $cli->command(new TaskState());
$cli->command(new SchedulerStart()); $cli->command(new SchedulerResumeTasks());
$cli->command(new SchedulerStop()); $cli->command(new SchedulerPauseTasks());
$cli->command(new SchedulerState()); $cli->command(new SchedulerState());
$cli->command(new TaskManagerCommand()); $cli->command(new SchedulerRun());
$cli->command(new TaskList()); $cli->command(new TaskList());
$cli->command(new TaskStart());
$cli->command(new TaskStop());
$cli->command(new MailTest('mail:test')); $cli->command(new MailTest('mail:test'));

View File

@@ -16,12 +16,12 @@ use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class SchedulerStop extends Command class SchedulerPauseTasks extends Command
{ {
public function __construct() public function __construct()
{ {
parent::__construct('task-manager:scheduler:stop'); parent::__construct('task-manager:scheduler:pause-tasks');
$this->setDescription('Starts Task-Manager scheduler. It updates the scheduler configuration.'); $this->setDescription('Pause scheduler started tasks jobs');
} }
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)

View File

@@ -16,12 +16,12 @@ use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class SchedulerStart extends Command class SchedulerResumeTasks extends Command
{ {
public function __construct() public function __construct()
{ {
parent::__construct('task-manager:scheduler:start'); parent::__construct('task-manager:scheduler:resume-tasks');
$this->setDescription('Starts Task-Manager scheduler'); $this->setDescription('Resume scheduler started tasks jobs');
} }
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)

View File

@@ -18,11 +18,12 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class TaskManagerCommand extends Command class SchedulerRun extends Command
{ {
public function __construct() public function __construct()
{ {
parent::__construct('task-manager:scheduler:run'); parent::__construct('task-manager:scheduler:run');
$this->setDescription('Run the scheduler');
} }
public function signalHandler($signal) public function signalHandler($signal)

View File

@@ -23,7 +23,7 @@ class SchedulerState extends Command
{ {
parent::__construct('task-manager:scheduler:state'); parent::__construct('task-manager:scheduler:state');
$this $this
->setDescription('Returns Task-Manager scheduler state') ->setDescription('Returns scheduler state')
->addOption('short', null, InputOption::VALUE_NONE, 'print short result, ie: <info>stopped()</info> | <info>started(12345)</info> | <info>tostop(12345)</info> | <info>stopping(12345)</info>'); ->addOption('short', null, InputOption::VALUE_NONE, 'print short result, ie: <info>stopped()</info> | <info>started(12345)</info> | <info>tostop(12345)</info> | <info>stopping(12345)</info>');
} }

View File

@@ -21,6 +21,7 @@ class TaskList extends Command
public function __construct() public function __construct()
{ {
parent::__construct('task-manager:task:list'); parent::__construct('task-manager:task:list');
$this->setDescription('Lists tasks');
} }
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)
@@ -30,7 +31,7 @@ class TaskList extends Command
$rows = array_map(function (Task $task) use ($probe, &$errors) { $rows = array_map(function (Task $task) use ($probe, &$errors) {
$info = $probe->getTask($task); $info = $probe->getTask($task);
$error = $info['actual'] !== $info['configuration']; $error = $info['actual'] !== $task->getStatus();
if ($error) { if ($error) {
$errors ++; $errors ++;
} }
@@ -38,8 +39,8 @@ class TaskList extends Command
return array( return array(
$task->getId(), $task->getId(),
$task->getName(), $task->getName(),
$task->getStatus(), $task->getStatus() !== 'started' ? $task->getStatus() . " (warning)" : $task->getStatus(),
$error ? "<error>" . $info['actual'] . "</error>" : $info['actual'], $error ? $info['actual'] . " (error)" : $info['actual'],
$info['process-id'], $info['process-id'],
); );
}, $this->container['manipulator.task']->getRepository()->findAll()); }, $this->container['manipulator.task']->getRepository()->findAll());

View File

@@ -31,7 +31,9 @@ class TaskRun extends Command
{ {
parent::__construct('task-manager:task:run'); parent::__construct('task-manager:task:run');
$this->addArgument('task_id', InputArgument::REQUIRED, 'The id of the task to run', null) $this
->setDescription('Runs a task')
->addArgument('task_id', InputArgument::REQUIRED, 'The id of the task to run', null)
->addOption('max-memory', null, InputOption::VALUE_REQUIRED, '') ->addOption('max-memory', null, InputOption::VALUE_REQUIRED, '')
->addOption('max-duration', null, InputOption::VALUE_REQUIRED, '') ->addOption('max-duration', null, InputOption::VALUE_REQUIRED, '')
->addOption('listen-signal', null, InputOption::VALUE_NONE, '') ->addOption('listen-signal', null, InputOption::VALUE_NONE, '')

View File

@@ -25,7 +25,7 @@ class TaskState extends Command
$this $this
->addArgument('task_id', InputArgument::REQUIRED, 'The task_id to test') ->addArgument('task_id', InputArgument::REQUIRED, 'The task_id to test')
->setDescription('Returns a Phraseanet task state given its id') ->setDescription('Returns the state of a task')
->addOption('short', null, InputOption::VALUE_NONE, 'print short result, ie: <info>stopped()</info> | <info>started(12345)</info> | <info>tostop(12345)</info> | <info>...</info>'); ->addOption('short', null, InputOption::VALUE_NONE, 'print short result, ie: <info>stopped()</info> | <info>started(12345)</info> | <info>tostop(12345)</info> | <info>...</info>');
} }

View File

@@ -53,7 +53,7 @@ class TaskList implements TaskListInterface
$arguments[] = $this->root . '/bin/console'; $arguments[] = $this->root . '/bin/console';
$arguments[] = '--'; $arguments[] = '--';
$arguments[] = '-q'; $arguments[] = '-q';
$arguments[] = 'task:run'; $arguments[] = 'task-manager:task:run';
$arguments[] = $task->getId(); $arguments[] = $task->getId();
$arguments[] = '--listen-signal'; $arguments[] = '--listen-signal';
$arguments[] = '--max-duration'; $arguments[] = '--max-duration';