-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathdetached.js
52 lines (48 loc) · 1.73 KB
/
detached.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
let co = require('co')
let cli = require('heroku-cli-util')
let helpers = require('../../lib/helpers')
let logDisplayer = require('../../lib/log_displayer')
let Dyno = require('../../lib/dyno')
const { DynoSizeCompletion, ProcessTypeCompletion } = require('@heroku-cli/command/lib/completions')
function * run (context, heroku) {
let opts = {
heroku: heroku,
app: context.app,
command: helpers.buildCommand(context.args),
size: context.flags.size,
type: context.flags.type,
env: context.flags.env,
attach: false
}
if (!opts.command) throw new Error('Usage: heroku run COMMAND\n\nExample: heroku run bash')
let dyno = new Dyno(opts)
yield dyno.start()
if (context.flags.tail) {
yield logDisplayer(heroku, {
app: context.app,
dyno: dyno.dyno.name,
tail: true
})
} else {
cli.log(`Run ${cli.color.cmd('heroku logs --app ' + dyno.opts.app + ' --dyno ' + dyno.dyno.name)} to view the output.`)
}
}
module.exports = {
topic: 'run',
command: 'detached',
description: 'run a detached dyno, where output is sent to your logs',
examples: `$ heroku run:detached ls
Running ls on app [detached]... up, run.1
Run heroku logs -a app -p run.1 to view the output.`,
variableArgs: true,
needsAuth: true,
needsApp: true,
flags: [
{ name: 'size', char: 's', description: 'dyno size', hasValue: true, completion: DynoSizeCompletion },
{ name: 'tail', char: 't', description: 'stream logs from the dyno' },
{ name: 'type', description: 'process type', hasValue: true, completion: ProcessTypeCompletion },
{ name: 'env', char: 'e', description: "environment variables to set (use ';' to split multiple vars)", hasValue: true }
],
run: cli.command(co.wrap(run))
}