fix bad conflict correction

This commit is contained in:
jygaulier
2012-05-02 18:59:25 +02:00
parent 6d822237da
commit 864a62782d

View File

@@ -65,61 +65,51 @@ class module_console_taskrun extends Command
}
}
public function execute(InputInterface $input, OutputInterface $output)
{
if ( ! setup::is_installed()) {
if ($this->task) {
$this->task->log(sprintf("signal %s received", $signo));
if ($signo == SIGTERM)
$this->task->set_running(false);
}
}
// printf("%s (%d) execute\n", __FILE__, __LINE__);
}
public function execute(InputInterface $input, OutputInterface $output)
{
if ( ! setup::is_installed()) {
$output->writeln('Phraseanet is not set up');
return 1;
}
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
throw new \RuntimeException('Argument must be an Id.');
$task_id = (int) $input->getArgument('task_id');
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
throw new \RuntimeException('Argument must be an Id.');
$appbox = \appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox);
$this->task = $task_manager->get_task($task_id);
$appbox = \appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox);
$this->task = $task_manager->get_task($task_id);
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
$schedStatus = $task_manager->get_scheduler_state();
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
$schedStatus = $task_manager->get_scheduler_state();
// printf("%s (%d) schedStatus=%s \n", __FILE__, __LINE__, var_export($schedStatus, true));
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
$this->shedulerPID = $schedStatus['pid'];
$runner = task_abstract::RUNNER_MANUAL;
}
else {
$runner = task_abstract::RUNNER_SCHEDULER;
$schedStatus = $task_manager->get_scheduler_state();
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
$this->shedulerPID = $schedStatus['pid'];
}
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
$this->shedulerPID = $schedStatus['pid'];
$runner = task_abstract::RUNNER_MANUAL;
}
else {
$runner = task_abstract::RUNNER_SCHEDULER;
$schedStatus = $task_manager->get_scheduler_state();
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
$this->shedulerPID = $schedStatus['pid'];
}
register_tick_function(array($this, 'tick_handler'), true);
declare(ticks = 1);
if (function_exists('pcntl_signal'))
pcntl_signal(SIGTERM, array($this, 'sig_handler'));
register_tick_function(array($this, 'tick_handler'), true);
declare(ticks = 1);
if (function_exists('pcntl_signal'))
pcntl_signal(SIGTERM, array($this, 'sig_handler'));
try {
$this->task->run($runner, $input, $output);
try {
$this->task->run($runner, $input, $output);
// $this->task->log(sprintf("%s [%d] taskrun : returned from 'run()', get_status()=%s \n", __FILE__, __LINE__, $this->task->get_status()));
} catch (Exception $e) {
$this->task->log(sprintf("taskrun : exception from 'run()', %s \n", $e->getMessage()));
return($e->getCode());
}
} catch (Exception $e) {
$this->task->log(sprintf("taskrun : exception from 'run()', %s \n", $e->getMessage()));
return($e->getCode());
}
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
$runner = task_abstract::RUNNER_MANUAL;
}
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
$runner = task_abstract::RUNNER_MANUAL;
}
}