|
|
@ -10,7 +10,7 @@ import { |
|
|
|
sub, |
|
|
|
sub, |
|
|
|
} from '../../accessModule'; |
|
|
|
} from '../../accessModule'; |
|
|
|
import { sanitize } from '../../sanitize'; |
|
|
|
import { sanitize } from '../../sanitize'; |
|
|
|
import { rm, stderr, stdoutVar } from '../../shell'; |
|
|
|
import { rm, stderr, stdoutVar, systemCall } from '../../shell'; |
|
|
|
|
|
|
|
|
|
|
|
export const createHostConnection: RequestHandler< |
|
|
|
export const createHostConnection: RequestHandler< |
|
|
|
unknown, |
|
|
|
unknown, |
|
|
@ -100,17 +100,29 @@ export const createHostConnection: RequestHandler< |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const [rawIsPeerDBReachable]: [output: string, returnCode: number] = |
|
|
|
const now = String(Date.now()); |
|
|
|
await sub('call', { |
|
|
|
|
|
|
|
params: [ |
|
|
|
const rawIsPeerDBReachable = systemCall( |
|
|
|
{ |
|
|
|
SERVER_PATHS.usr.bin.psql.self, |
|
|
|
shell_call: `PGPASSFILE="${pgpassFilePath}" ${SERVER_PATHS.usr.bin.psql.self} --host ${peerIPAddress} --port ${commonDBPort} --dbname ${commonDBName} --username ${commonDBUser} --no-password --tuples-only --no-align --command "SELECT 1"`, |
|
|
|
[ |
|
|
|
}, |
|
|
|
'--no-align', |
|
|
|
], |
|
|
|
'--no-password', |
|
|
|
pre: ['System'], |
|
|
|
'--tuples-only', |
|
|
|
}); |
|
|
|
'--command', |
|
|
|
|
|
|
|
`SELECT ${now};`, |
|
|
|
isPeerDBReachable = rawIsPeerDBReachable === '1'; |
|
|
|
'--dbname', |
|
|
|
|
|
|
|
commonDBName, |
|
|
|
|
|
|
|
'--host', |
|
|
|
|
|
|
|
peerIPAddress, |
|
|
|
|
|
|
|
'--port', |
|
|
|
|
|
|
|
String(commonDBPort), |
|
|
|
|
|
|
|
'--username', |
|
|
|
|
|
|
|
commonDBUser, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
{ env: { PGPASSFILE: pgpassFilePath } }, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isPeerDBReachable = rawIsPeerDBReachable === now; |
|
|
|
} catch (subError) { |
|
|
|
} catch (subError) { |
|
|
|
stderr(`Failed to test connection to peer database; CAUSE: ${subError}`); |
|
|
|
stderr(`Failed to test connection to peer database; CAUSE: ${subError}`); |
|
|
|
} |
|
|
|
} |
|
|
|