fix(striker-ui-api): trim peer database echo output in create host connection

main
Tsu-ba-me 1 year ago
parent a5fc7d499e
commit 12e257357d
  1. 13
      striker-ui-api/src/lib/request_handlers/host/createHostConnection.ts

@ -93,16 +93,16 @@ export const createHostConnection: RequestHandler<
} }
try { try {
const now = String(Date.now()); const timestamp = String(Date.now());
const rawIsPeerDBReachable = systemCall( const echo = systemCall(
SERVER_PATHS.usr.bin.psql.self, SERVER_PATHS.usr.bin.psql.self,
[ [
'--no-align', '--no-align',
'--no-password', '--no-password',
'--tuples-only', '--tuples-only',
'--command', '--command',
`SELECT ${now};`, `SELECT ${timestamp};`,
'--dbname', '--dbname',
commonDBName, commonDBName,
'--host', '--host',
@ -113,9 +113,14 @@ export const createHostConnection: RequestHandler<
commonDBUser, commonDBUser,
], ],
{ env: { PGPASSFILE: pgpassFilePath } }, { env: { PGPASSFILE: pgpassFilePath } },
).trim();
stdoutVar(
{ timestamp, echo },
'Ask the peer database to echo the current timestamp: ',
); );
isPeerDBReachable = rawIsPeerDBReachable === now; isPeerDBReachable = echo === timestamp;
} catch (subError) { } catch (subError) {
stderr(`Failed to test connection to peer database; CAUSE: ${subError}`); stderr(`Failed to test connection to peer database; CAUSE: ${subError}`);
} }

Loading…
Cancel
Save