13,
\task_manager::STATE_STARTED => 10,
\task_manager::STATE_STOPPING => 12,
\task_manager::STATE_STOPPED => 11,
);
public function __construct($name = null)
{
parent::__construct($name);
$this->setDescription('Returns Phraseanet scheduler status');
$this->addOption(
'short'
, NULL
, InputOption::VALUE_NONE
, 'print short result, ie: stopped() | started(12345) | tostop(12345) | stopping(12345)'
, NULL
);
return $this;
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
if (!$this->container['phraseanet.configuration-tester']->isInstalled()) {
return self::EXITCODE_SETUP_ERROR;
}
$task_manager = $this->container['task-manager'];
$exitCode = 0;
$state = $task_manager->getSchedulerState();
if ($input->getOption('short')) {
$output->writeln(sprintf('%s(%s)', $state['status'], $state['pid']));
} else {
if ($state['pid'] != NULL) {
$output->writeln(sprintf(
'Scheduler is %s on pid %d'
, $state['status']
, $state['pid']
));
} else {
$output->writeln(sprintf('Scheduler is %s', $state['status']));
}
}
if (array_key_exists($state['status'], $this->stateToExitCode)) {
$exitCode = $this->stateToExitCode[$state['status']];
} else {
$exitCode = self::EXITCODE_STATE_UNKNOWN;
}
return $exitCode;
}
}