Exemple #1
0
    # run command as locally ChRIS!
    $ssh2 = new Net_SSH2('localhost');
    $key = new Crypt_RSA();
    $sshkey = joinPaths(CHRIS_HOME, '.ssh/id_rsa');
    $key->loadKey(file_get_contents($sshkey));
    if (!$ssh2->login('chris', $key)) {
        exit('Login as ChRIS local user failed...!');
    }
    $local_command = "/bin/bash umask 0002;/bin/bash {$runfile};";
    $nohup_wrap = 'bash -c \'nohup bash -c "' . $local_command . '" > /dev/null 2>&1 &\'';
    $ssh2->exec($nohup_wrap);
    $pid = -1;
} else {
    if ($status == 100) {
        // run locally
        $ssh->exec('bash -c \' /bin/bash ' . $runfile . '\'');
        $pid = -1;
    } else {
        // run on cluster and return pid
        $cluster_command = str_replace("{MEMORY}", $memory, CLUSTER_RUN);
        $cluster_command = str_replace("{FEED_ID}", $feed_id, $cluster_command);
        $cluster_command = str_replace("{COMMAND}", "/bin/bash " . $runfile, $cluster_command);
        $pid = $ssh->exec('bash -c \'' . $cluster_command . '\'');
    }
}
// attach pid to feed
$metaObject = new Meta();
$metaObject->name = "pid";
$metaObject->value = $pid;
FeedC::addMeta($feed_id, array(0 => $metaObject));
echo $feed_id;