mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
add mode 'dryrun', actually check if a task is due
This commit is contained in:
parent
98374b513d
commit
2bd75c6d1f
|
@ -19,7 +19,7 @@ function usage() { /* {{{ */
|
|||
echo " -h, --help: print usage information and exit.\n";
|
||||
echo " -v, --version: print version and exit.\n";
|
||||
echo " --config: set alternative config file.\n";
|
||||
echo " --mode: set mode of operation (run, check, list).\n";
|
||||
echo " --mode: set mode of operation (run, dryrun, check, list).\n";
|
||||
} /* }}} */
|
||||
|
||||
$version = "0.0.1";
|
||||
|
@ -49,7 +49,7 @@ if(isset($options['config'])) {
|
|||
|
||||
$mode = 'list';
|
||||
if(isset($options['mode'])) {
|
||||
if(!in_array($options['mode'], array('run', 'check', 'list'))) {
|
||||
if(!in_array($options['mode'], array('run', 'dryrun', 'check', 'list'))) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
@ -71,15 +71,20 @@ foreach($tasks as $task) {
|
|||
if(isset($GLOBALS['SEEDDMS_SCHEDULER']['tasks'][$task->getExtension()]) && is_object($taskobj = $GLOBALS['SEEDDMS_SCHEDULER']['tasks'][$task->getExtension()][$task->getTask()])) {
|
||||
switch($mode) {
|
||||
case "run":
|
||||
case "dryrun":
|
||||
if(method_exists($taskobj, 'execute')) {
|
||||
if(!$task->getDisabled()) {
|
||||
if(!$task->getDisabled() && $task->isDue()) {
|
||||
if($user = $dms->getUserByLogin('cli_scheduler')) {
|
||||
if($taskobj->execute($task, $dms, $user)) {
|
||||
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
|
||||
$task->updateLastNextRun();
|
||||
} else {
|
||||
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR);
|
||||
$task->setDisabled(1);
|
||||
if($mode == 'run') {
|
||||
if($taskobj->execute($task, $dms, $user)) {
|
||||
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
|
||||
$task->updateLastNextRun();
|
||||
} else {
|
||||
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR);
|
||||
$task->setDisabled(1);
|
||||
}
|
||||
} elseif($mode == 'dryrun') {
|
||||
echo "Running ".$task->getExtension()."::".$task->getTask()."\n";
|
||||
}
|
||||
} else {
|
||||
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed because of missing user 'cli_scheduler'. Task has been disabled.", PEAR_LOG_ERR);
|
||||
|
|
Loading…
Reference in New Issue
Block a user