|
|
@ -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}`); |
|
|
|
} |
|
|
|
} |
|
|
|