Example #1
0
function get_string($f, $exit = true)
{
    $t = false;
    while (!$t && !feof($f)) {
        $t = preg_replace("/\\s+\$/", "", fgets($f));
    }
    if (!$t && $exit) {
        do_exit();
    }
    return $t;
}
function print_log($message, $function = '', $type = 0, $is_exit = false)
{
    $log_type = '';
    if ($type == 0) {
        $log_type = '[ERROR]';
    } else {
        if ($type == 1) {
            $log_type = '[INFO]';
        }
    }
    echo $log_type . ' ' . ($type === 0 ? $function : '+') . ': ' . $message . br2();
    if ($is_exit) {
        do_exit();
    }
}
Example #3
0
    $jobinfo["exec_type"] = "local";
    // default execution type is local execution
}
$pid = $jobinfo["pid"];
if ($pid > 0 && $jobinfo["exec_type"] === "local") {
    $ret = -1;
    $output = "";
    // uses the script killtree.sh
    exec($killtree_path . " " . $pid . " KILL", $output, $ret);
    if ($ret == 0) {
        $jobinfo["status"] = JobStatus::$KILLED;
        save_job_info($study, $jobid, $jobinfo);
        do_exit($jobid, $pid, JobStatus::$KILLED);
    } else {
        do_exit($jobid, $pid, JobStatus::$FINISHED);
    }
} else {
    if ($pid > 0 && $jobinfo["exec_type"] === "remote") {
        $ret = _kill_job_remote($jobinfo);
        if ($ret == 0) {
            $jobinfo["status"] = JobStatus::$KILLED;
            save_job_info($study, $jobid, $jobinfo);
            do_exit($jobid, $pid, JobStatus::$KILLED);
        } else {
            do_exit($jobid, $pid, JobStatus::$FINISHED);
        }
    } else {
        do_exit($jobid, $pid, "ERROR: Wrong pid " . $pid);
    }
}
exit;
Example #4
0
    }
}
// If we have pcntl - set up a handler for sigterm
if (function_exists('pcntl_signal')) {
    declare (ticks=1);
    pcntl_signal(SIGABRT, 'do_exit');
    pcntl_signal(SIGHUP, 'do_exit');
    pcntl_signal(SIGQUIT, 'do_exit');
    pcntl_signal(SIGINT, 'do_exit');
    pcntl_signal(SIGTERM, 'do_exit');
}
// Go!
$engine->run($url);
//run queue's
//var_dump($queue);
do_exit();
/**
 * -------
 * Execution ends here - Some functions are defined next
 * -------
 */
/**
 * Show usage message
 *
 * @return void
 */
function spizer_usage()
{
    global $argv;
    $ver = SPIZER_VERSION;
    $usage = <<<USAGE