2012-05-31 11:40:49 +08:00
|
|
|
var helper = require(__dirname + '/../test-helper');
|
|
|
|
var exec = require('child_process').exec;
|
|
|
|
|
|
|
|
helper.pg.defaults.poolIdleTimeout = 1000;
|
|
|
|
|
|
|
|
helper.pg.connect(helper.config, function(err,client) {
|
|
|
|
client.query("SELECT pg_backend_pid()", function(err, result) {
|
|
|
|
var pid = result.rows[0].pg_backend_pid;
|
2015-12-04 23:28:01 +08:00
|
|
|
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) {
|
2012-05-31 11:40:49 +08:00
|
|
|
assert.isNull(error);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
helper.pg.on('error', function(err, client) {
|
|
|
|
//swallow errors
|
|
|
|
});
|