コード例 #1
0
ファイル: UploadTask.php プロジェクト: muxx/dplr
 /**
  * Add task to pssh task list for server
  *
  * @access public
  * @abstract
  * @return integer
  */
 protected function initTaskList()
 {
     foreach ($this->getServers() as $server) {
         $result = pssh_copy_to_server($this->psshTaskHandler, $server, $this->getLocalFile(), $this->getRemoteFile(), $this->getTimeout());
         if (!$result) {
             throw new \RuntimeException(sprintf('Failed to add upload task for server %s', $server));
         }
         $this->taskReports[] = new UploadTaskReport($this->getLocalFile(), $this->getRemoteFile(), $server);
     }
     return true;
 }
コード例 #2
0
ファイル: pssh.php プロジェクト: badoo/pssh_extension
do {
    $ret = pssh_connect($r, $server, 3);
    switch ($ret) {
        case PSSH_CONNECTED:
            echo "connected to ", $server, "\n";
            unset($servers[array_search($server, $servers)]);
            break;
    }
} while ($ret == PSSH_CONNECTED);
if ($ret == PSSH_SUCCESS) {
    echo "all servers connected\n";
} else {
    echo "failed to connect to: ", implode(", ", $servers), "\n";
}
/* create a task */
$tl = pssh_tasklist_init($r);
pssh_copy_to_server($tl, $server, $local_file, $remote_file);
/* execute the task */
do {
} while (pssh_tasklist_exec($tl, $server, 10) == PSSH_RUNNING);
/* output a report */
$failed = $succeeded = 0;
for ($t = pssh_tasklist_first($tl); $t; $t = pssh_tasklist_next($tl)) {
    if (pssh_task_status($t) == PSSH_TASK_DONE) {
        $succeeded++;
    } else {
        $failed++;
    }
}
echo "Commands succeeded: " . $succeeded . "\n";
echo "Commands failed: " . $failed . "\n";