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

Loading…
Cancel
Save