cmd now prepends exec to command; pipes get closed
This commit is contained in:
parent
463ef7cd37
commit
ea0118d445
1 changed files with 7 additions and 5 deletions
|
@ -243,7 +243,7 @@ if ($restore) {
|
|||
$host=$insts[$buf[$i]+0];
|
||||
eecho(1,'bootstrapping processes pool, adding host «'.$host.'».'.N);
|
||||
$descspecs=[ 0=>['pipe','r'], 1=>['pipe','w'], 2=>['file',$rundirpath.'/'.$host.'.stderr.log','w'] ];
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes), 'instk'=>$buf[$i]+0, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes[]), 'instk'=>$buf[$i]+0, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
}
|
||||
eecho(1,'restored previous session.'.N);
|
||||
} else {
|
||||
|
@ -315,7 +315,7 @@ if ($restore) {
|
|||
$host=$insts[$instk];
|
||||
eecho(1,'bootstrapping processes pool, adding host «'.$host.'».'.N);
|
||||
$descspecs=[ 0=>['pipe','r'], 1=>['pipe','w'], 2=>['file',$rundirpath.'/'.$host.'.stderr.log','w'] ];
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes), 'instk'=>$instk, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes[]), 'instk'=>$instk, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
}
|
||||
$instk--;
|
||||
|
||||
|
@ -329,16 +329,18 @@ do {
|
|||
eecho(0,'[[[ CHECKING PROCESSES POOL ]]]'.N);
|
||||
$somerun=false;
|
||||
foreach ($procs as $key=>$proc) {
|
||||
if (!is_null($proc)) {
|
||||
if (!is_null($proc) && is_resource($proc['proc'])) {
|
||||
$pstat=proc_get_status($proc['proc']);
|
||||
if (!$pstat['running']) {
|
||||
fclose($pipes[$key][0]);
|
||||
fclose($pipes[$key][1]);
|
||||
$done++;
|
||||
$out='proc slot '.$key.': finished running on «'.$proc['host'].'» (exit code: '.$pstat['exitcode'].')';
|
||||
if ($instk<$cinsts-1) {
|
||||
$instk++;
|
||||
$host=$insts[$instk];
|
||||
$descspecs=[ 0=>['pipe','r'], 1=>['pipe','w'], 2=>['file',$rundirpath.'/'.$host.'.stderr.log','w'] ];
|
||||
$procs[$key]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes), 'instk'=>$instk, 'host'=>$host, 'begts'=>$now];
|
||||
$procs[$key]=['proc'=>proc_open(cmd($childopts,$host),$descspecs,$pipes[$key]), 'instk'=>$instk, 'host'=>$host, 'begts'=>$now];
|
||||
$out.='; started a new process on «'.$host.'».'.N;
|
||||
} else {
|
||||
$out.='; no more hosts to check.'.N;
|
||||
|
@ -383,7 +385,7 @@ function writestatus(&$statusjfp,&$opts,&$instk,&$tet,&$done,&$procs) {
|
|||
}
|
||||
|
||||
function cmd(&$childopts, &$host) {
|
||||
return(__DIR__.'/'.CHILD.$childopts.' '.escapeshellarg($host));
|
||||
return('exec '.__DIR__.'/'.CHILD.$childopts.' '.escapeshellarg($host));
|
||||
}
|
||||
|
||||
function eecho($lev,$msg) {
|
||||
|
|
Loading…
Reference in a new issue