Esempio n. 1
0
 function run($args = array())
 {
     global $TASKMAN_CURRENT_TASK;
     global $TASKMAN_STACK;
     $args_str = serialize($args);
     if (isset($this->has_run[$args_str]) && $this->has_run[$args_str] || $this->is_running) {
         return;
     }
     $this->is_running = true;
     $this->args = $args;
     try {
         if ($task_handler = taskman_config('task_handler')) {
             $task_handler($this);
         }
         taskman_runtasks($this->_getBeforeDeps(), $this->args);
         taskman_runtasks($this->_getDeps(), $this->args);
         taskman_sysmsg("************************ Running task '" . $this->getName() . "' ************************\n");
         $bench = microtime(true);
         $TASKMAN_CURRENT_TASK = $this;
         $TASKMAN_STACK[] = $this;
         if ($replacer = $this->_getReplacingTask()) {
             taskman_runtask($replacer, $this->args);
         } else {
             call_user_func_array($this->func, array($this->args));
         }
         array_pop($TASKMAN_STACK);
         taskman_runtasks($this->_getAfterDeps(), $this->args);
         taskman_sysmsg("************************* '" . $this->getName() . "' done (" . round(microtime(true) - $bench, 2) . " sec.)*************************\n");
         $this->has_run[$args_str] = true;
         $this->is_running = false;
     } catch (Exception $e) {
         if ($error_handler = taskman_config('error_handler')) {
             $error_handler($e);
         } else {
             throw $e;
         }
     }
 }
Esempio n. 2
0
function runtask($task, $args = array())
{
    return \taskman_runtask($task, $args);
}
Esempio n. 3
0
function taskman_runtasks($tasks, $args = array())
{
    foreach ($tasks as $task_spec) {
        if (is_scalar($task_spec)) {
            taskman_runtask($task_spec, $args);
        } else {
            if (is_array($task_spec)) {
                taskman_runtasks_parall($task_spec, $args);
            } else {
                if (is_object($task_spec)) {
                    $task_spec->run($args);
                } else {
                    throw new TaskmanException("Invalid task specification '{$task_spec}', should be either string or array or object");
                }
            }
        }
    }
}
Esempio n. 4
0
<?php

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");
require_once dirname(__FILE__) . '/../setup.php';
require_once dirname(__FILE__) . '/../src/syncmanctl.inc.php';
if (!isset($_GET['cmd'])) {
    exit;
}
$args = array();
if (isset($_GET['args'])) {
    $args = explode(',', $_GET['args']);
}
taskman_collecttasks();
taskman_runtask($_GET['cmd'], $args);