isConnected() public method

Is the connection still active?
public isConnected ( ) : boolean
return boolean
Ejemplo n.º 1
0
 /**
  * @return bool
  */
 public function isConnected()
 {
     return $this->ssh->isConnected();
 }
Ejemplo n.º 2
0
}
//send input file to cr2g server
$sftp->mkdir('/code/spopt-stable/tests/' . $session);
$sftp->put($remoteInputFile, $localInputFile, NET_SFTP_LOCAL_FILE);
$sftp->chmod(0777, $remoteInputFile);
//execute python script in this order to run the Solver:
//1. change to directory where solver script is located
$ssh->write("cd /code/spopt-stable\n");
//2. 'read' command to ensure script is called from the proper directory
$ssh->read('rlgruver@cr2g01:/code/spopt-stable$');
//3. run the solver script with the test from the current session
$ssh->write("python SpOpt.py tests/" . $session . "/input.txt\n");
//start timerin case anything gets stuck, will break within 120 minutes (7200 sec)
$starttime = time();
//ssh will break within 120 minutes (7200 sec) regardless of execution status
while ($ssh->isConnected()) {
    $now = time() - $starttime;
    if ($now > 7200) {
        break;
    }
    sleep(3);
    //retrieve all solutions/discarded from cr2g and store in local
    $sftp->get($remoteSolutionsFile, $localSolutionsFile);
    $sftp->get($remoteDiscardedFile, $localDiscardedFile);
    //function to provide discarded solutions during session
    parseDiscarded($session);
    //if final output file gets created from the cr2g sever, store it in local and complete
    if ($sftp->get($remoteOutputFile, $localOutputFile)) {
        $done = "true";
        break;
    }