From e670e0f94cc79942a2fdb3ee5470693f879cc83f Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 17 Nov 2023 08:09:22 -0500 Subject: [PATCH] fix(striker-ui-api): distinguish processes in messages --- striker-ui-api/src/index.ts | 6 +++--- striker-ui-api/src/lib/accessModule.ts | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/striker-ui-api/src/index.ts b/striker-ui-api/src/index.ts index 81eb71cc..ca53409a 100644 --- a/striker-ui-api/src/index.ts +++ b/striker-ui-api/src/index.ts @@ -7,7 +7,7 @@ import { proxyServerVncUpgrade } from './middlewares'; import { stderr, stdout } from './lib/shell'; (async () => { - stdout(`Starting process with ownership ${getuid()}:${getgid()}`); + stdout(`Starting main process with ownership ${getuid()}:${getgid()}`); const server = (await app).listen(PORT, () => { try { @@ -15,9 +15,9 @@ import { stderr, stdout } from './lib/shell'; setgid(PGID); setuid(PUID); - stdout(`Process ownership changed to ${getuid()}:${getgid()}.`); + stdout(`Main process ownership changed to ${getuid()}:${getgid()}.`); } catch (error) { - stderr(`Failed to change process ownership; CAUSE: ${error}`); + stderr(`Failed to change main process ownership; CAUSE: ${error}`); process.exit(ECODE_DROP_PRIVILEGES); } diff --git a/striker-ui-api/src/lib/accessModule.ts b/striker-ui-api/src/lib/accessModule.ts index 1b5384e6..6eea2a93 100644 --- a/striker-ui-api/src/lib/accessModule.ts +++ b/striker-ui-api/src/lib/accessModule.ts @@ -36,10 +36,9 @@ class Access extends EventEmitter { uid = PUID, ...restSpawnOptions }: AccessStartOptions = {}) { - shvar( - { gid, stdio, timeout, uid, ...restSpawnOptions }, - `Starting anvil-access-module daemon with options: `, - ); + const options = { args, gid, stdio, timeout, uid, ...restSpawnOptions }; + + shvar(options, `Starting anvil-access-module daemon with: `); const ps = spawn(SERVER_PATHS.usr.sbin['anvil-access-module'].self, args, { gid, @@ -49,13 +48,24 @@ class Access extends EventEmitter { ...restSpawnOptions, }); + ps.on('spawn', () => { + shvar( + options, + `Successfully started anvil-access-module daemon (pid=${ps.pid}): `, + ); + }); + ps.on('error', (error) => { - sherr(`anvil-access-module daemon error: ${error.message}`, error); + sherr( + `anvil-access-module daemon (pid=${ps.pid}) error: ${error.message}`, + error, + ); }); ps.on('close', (code, signal) => { - shout( - `anvil-access-module daemon exited; code=${code}, signal=${signal}`, + shvar( + { code, options, signal }, + `anvil-access-module daemon (pid=${ps.pid}) closed: `, ); });