This commit is contained in:
jygaulier
2012-01-31 19:21:06 +01:00
parent 5a5f86a97b
commit 72078aa836
13 changed files with 1040 additions and 1305 deletions

View File

@@ -29,6 +29,20 @@ class module_console_schedulerStart extends Command
parent::__construct($name);
$this->setDescription('Start the scheduler');
$this->addOption(
'nolog'
, NULL
, 1 | InputOption::VALUE_NONE
, 'do not log (scheduler) to logfile'
, NULL
);
$this->addOption(
'notasklog'
, NULL
, 1 | InputOption::VALUE_NONE
, 'do not log (tasks) to logfiles'
, NULL
);
$this->setHelp(
"You should use launch the command and finish it with `&`"
. " to return to the console\n\n"
@@ -38,7 +52,7 @@ class module_console_schedulerStart extends Command
return $this;
}
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $zinput, OutputInterface $output)
{
if(!setup::is_installed())
{
@@ -48,7 +62,7 @@ class module_console_schedulerStart extends Command
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
$scheduler = new task_Scheduler();
$scheduler->run($output, true);
$scheduler->run($zinput, $output); //, !$input->getOption('nolog'), !$input->getOption('notasklog'));
return;
}

View File

@@ -43,10 +43,27 @@ class module_console_taskrun extends Command
, 'The name of the runner (manual, scheduler...)'
, task_abstract::RUNNER_MANUAL
);
$this->addOption(
'nolog'
, NULL
, 1 | InputOption::VALUE_NONE
, 'do not log to logfile'
, NULL
);
$this->setDescription('Run task');
return $this;
}
function sig_handler($signo)
{
if($this->task)
{
$this->task->log(sprintf("signal %s received", $signo));
if($signo == SIGTERM)
$this->task->set_running(false);
}
}
public function execute(InputInterface $input, OutputInterface $output)
{
@@ -81,9 +98,12 @@ class module_console_taskrun extends Command
register_tick_function(array($this, 'tick_handler'), true);
declare(ticks=1);
pcntl_signal(SIGTERM, array($this, 'sig_handler'));
$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()));
$this->task->run($runner);
printf("TASK QUIT\n");
return $this;
}