I'm running some commands on multiple servers and I want them to all run concurrently,
foreach($clust['hosts'] as $hostStr) {
list($host, $port) = Str::rsplit($hostStr,':',2,22);
$ssh = new \Net_SSH2($host, $port);
if(!$ssh->login($username,$key)) {
throw new \Exception("Could not connect to $username@$host:$port");
}
$connections[] = $ssh;
}
foreach($connections as $i=>$ssh) {
$ssh->exec('cd /path/to/my/project && hg up', function($str) {
echo $str;
});
echo "right after ls $i\n";
}
But this always runs sequentially. Can I tell Net_SSH2
to be non-blocking?