mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
* Work on converting lib to standard * Finish updating lib * Finish linting lib * Format test files * Add .eslintrc with standard format * Supply full path to eslint bin * Move lint command to package.json * Add eslint as dev dependency
24 lines
786 B
JavaScript
24 lines
786 B
JavaScript
'use strict'
|
|
var helper = require(__dirname + '/../test-helper')
|
|
var exec = require('child_process').exec
|
|
|
|
helper.pg.defaults.poolIdleTimeout = 1000
|
|
|
|
const pool = new helper.pg.Pool()
|
|
pool.connect(function (err, client) {
|
|
client.query('SELECT pg_backend_pid()', function (err, result) {
|
|
var pid = result.rows[0].pg_backend_pid
|
|
var psql = 'psql'
|
|
if (helper.args.host) psql = psql + ' -h ' + helper.args.host
|
|
if (helper.args.port) psql = psql + ' -p ' + helper.args.port
|
|
if (helper.args.user) psql = psql + ' -U ' + helper.args.user
|
|
exec(psql + ' -c "select pg_terminate_backend(' + pid + ')" template1', assert.calls(function (error, stdout, stderr) {
|
|
assert.isNull(error)
|
|
}))
|
|
})
|
|
})
|
|
|
|
pool.on('error', function (err, client) {
|
|
// swallow errors
|
|
})
|