UNPKG

677 BJavaScriptView Raw
1'use strict'
2
3const cli = require('heroku-cli-util')
4const co = require('co')
5
6function * run (context, heroku) {
7 const fetcher = require('../lib/fetcher')(heroku)
8 const host = require('../lib/host')
9
10 yield cli.action('Terminating connections', co(function * () {
11 const db = yield fetcher.addon(context.app, context.args.database)
12 yield heroku.post(`/client/v11/databases/${db.id}/connection_reset`, {host: host(db)})
13 }))
14}
15
16module.exports = {
17 topic: 'pg',
18 command: 'killall',
19 description: 'terminates all connections',
20 needsApp: true,
21 needsAuth: true,
22 args: [{name: 'database', optional: true}],
23 run: cli.command({preauth: true}, co.wrap(run))
24}