modifs.mineures sans commentaires
This commit is contained in:
parent
218c097cc4
commit
d744775ccc
|
@ -18,17 +18,22 @@ class RunFile {
|
|||
|
||||
const NAME = null;
|
||||
|
||||
function __construct(string $file, ?string $name=null) {
|
||||
function __construct(?string $name, string $file, ?string $logfile=null) {
|
||||
$file = path::ensure_ext($file, self::RUN_EXT);
|
||||
$this->file = new SharedFile($file);
|
||||
$this->name = $name ?? static::NAME;
|
||||
$this->file = new SharedFile($file);
|
||||
$this->logfile = $logfile;
|
||||
}
|
||||
|
||||
/** @var SharedFile */
|
||||
protected $file;
|
||||
protected ?string $name;
|
||||
|
||||
/** @var ?string */
|
||||
protected $name;
|
||||
protected SharedFile $file;
|
||||
|
||||
protected ?string $logfile;
|
||||
|
||||
function getLogfile(): ?string {
|
||||
return $this->logfile;
|
||||
}
|
||||
|
||||
protected static function merge(array $data, array $merge): array {
|
||||
return cl::merge($data, [
|
||||
|
@ -36,9 +41,13 @@ class RunFile {
|
|||
], $merge);
|
||||
}
|
||||
|
||||
protected function initData(bool $withDateStart=true): array {
|
||||
$pid = $withDateStart? posix_getpid(): null;
|
||||
$dateStart = $withDateStart? new DateTime(): null;
|
||||
protected function initData(bool $forStart=true): array {
|
||||
if ($forStart) {
|
||||
$pid = posix_getpid();
|
||||
$dateStart = new DateTime();
|
||||
} else {
|
||||
$pid = $dateStart = null;
|
||||
}
|
||||
return [
|
||||
"name" => $this->name,
|
||||
"id" => bin2hex(random_bytes(16)),
|
||||
|
@ -50,6 +59,7 @@ class RunFile {
|
|||
"date_lock" => null,
|
||||
"date_release" => null,
|
||||
# run
|
||||
"logfile" => $this->logfile,
|
||||
"date_start" => $dateStart,
|
||||
"date_stop" => null,
|
||||
"exitcode" => null,
|
||||
|
|
|
@ -59,7 +59,7 @@ class launcher {
|
|||
"--internal-use", $tmpfile->getFile(),
|
||||
$appClass, "--", ...$args,
|
||||
]);
|
||||
$cmd->addRedir("both", "/tmp/_nulib_launch-launcher.log");
|
||||
$cmd->addRedir("both", "/tmp/nulib_app_launcher-launch.log");
|
||||
$cmd->passthru($exitcode);
|
||||
|
||||
# attendre un peu que la commande aie le temps de s'initialiser
|
||||
|
@ -82,13 +82,14 @@ class launcher {
|
|||
## child, fork ok
|
||||
# Créer un groupe de process, pour pouvoir les tuer toutes en même temps
|
||||
$runfile->tm_startPg();
|
||||
$logfile = $runfile->getLogfile() ?? "/tmp/nulib_app_launcher-_start.log";
|
||||
$pid = posix_getpid();
|
||||
$exitcode = -776;
|
||||
try {
|
||||
# puis lancer la commande
|
||||
$cmd = new Cmd($args);
|
||||
$cmd->addSource("/g/init.env");
|
||||
$cmd->addRedir("both", "/tmp/_nulib_launch-app.log");
|
||||
$cmd->addRedir("both", $logfile);
|
||||
#XXX prendre le fichier de log de $runfile si possible?
|
||||
msg::debug("$pid: launching\n".$cmd->getCmd());
|
||||
$cmd->fork_exec($exitcode);
|
||||
|
|
|
@ -351,12 +351,15 @@ class app {
|
|||
|
||||
function getRunfile(): RunFile {
|
||||
$name = $this->name;
|
||||
return $this->runfile ??= new RunFile($this->getWorkfile($name), $name);
|
||||
$runfile = $this->getWorkfile($name);
|
||||
$logfile = $this->getLogfile();
|
||||
return $this->runfile ??= new RunFile($name, $runfile, $logfile);
|
||||
}
|
||||
|
||||
protected ?LockFile $lockFile = null;
|
||||
protected ?array $lockFiles = null;
|
||||
|
||||
function getLockfile(): LockFile {
|
||||
return $this->lockFile ??= $this->getRunfile()->getLockFile(null, $this->title);
|
||||
function getLockfile(?string $name=null): LockFile {
|
||||
$this->lockFiles[$name] ??= $this->getRunfile()->getLockFile($name, $this->title);
|
||||
return $this->lockFiles[$name];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue