Removed stdout/err redirect in cmd; passing proper descriptor and pipe to proc_open; minor changes
This commit is contained in:
parent
a32a25e095
commit
a3ada274e7
1 changed files with 10 additions and 7 deletions
|
@ -181,8 +181,8 @@ elseif (!file_exists($rundirpath))
|
|||
if (@mkdir($rundirpath)===false)
|
||||
mexit('could not create directory «'.$rundirpath.'».'.N,1,false);
|
||||
|
||||
$instsjfp=$rundirpath.'/instances.job';
|
||||
$statusjfp=$rundirpath.'/status.job';
|
||||
$instsjfp=$rundirpath.'/'.FNAME.'_instances.job';
|
||||
$statusjfp=$rundirpath.'/'.FNAME.'_status.job';
|
||||
|
||||
(!$opts['dontrestore'] && file_exists($instsjfp) && file_exists($statusjfp)) ? $restore=true : $restore=false;
|
||||
|
||||
|
@ -221,7 +221,8 @@ if ($restore) {
|
|||
//eecho(0,$i.': '.$buf[$i].'.'.N);
|
||||
$host=$insts[$buf[$i]+0];
|
||||
eecho(1,'bootstrapping processes pool, adding host «'.$host.'».'.N);
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host,$rundirpath),[],$pipes[]), 'instk'=>$buf[$i]+0, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
$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)];
|
||||
}
|
||||
eecho(1,'restored previous session.'.N);
|
||||
} else {
|
||||
|
@ -292,7 +293,8 @@ if ($restore) {
|
|||
for ($instk=0; $instk<$opts['poolsize'] && $instk<$cinsts; $instk++) {
|
||||
$host=$insts[$instk];
|
||||
eecho(1,'bootstrapping processes pool, adding host «'.$host.'».'.N);
|
||||
$procs[]=['proc'=>proc_open(cmd($childopts,$host,$rundirpath),[],$pipes[]), 'instk'=>$instk, 'host'=>$host, 'begts'=>microtime(true)];
|
||||
$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)];
|
||||
}
|
||||
$instk--;
|
||||
|
||||
|
@ -314,7 +316,8 @@ do {
|
|||
if ($instk<$cinsts-1) {
|
||||
$instk++;
|
||||
$host=$insts[$instk];
|
||||
$procs[$key]=['proc'=>proc_open(cmd($childopts,$host,$rundirpath),[],$pipes[$key]), 'instk'=>$instk, 'host'=>$host, 'begts'=>$now];
|
||||
$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];
|
||||
$out.='; started a new process on «'.$host.'».'.N;
|
||||
} else {
|
||||
$out.='; no more hosts to check.'.N;
|
||||
|
@ -358,8 +361,8 @@ function writestatus(&$statusjfp,&$opts,&$instk,&$eta,&$done,&$procs) {
|
|||
fclose($f);
|
||||
}
|
||||
|
||||
function cmd(&$childopts, &$host, &$rundirpath) {
|
||||
return(__DIR__.'/'.CHILD.$childopts.' '.escapeshellarg($host).' &> '.$rundirpath.'/'.escapeshellarg($host).'.stdoe.log');
|
||||
function cmd(&$childopts, &$host) {
|
||||
return(__DIR__.'/'.CHILD.$childopts.' '.escapeshellarg($host));
|
||||
}
|
||||
|
||||
function eecho($lev,$msg) {
|
||||
|
|
Loading…
Reference in a new issue