forked from remind101/empire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.go
33 lines (28 loc) · 798 Bytes
/
runner.go
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
package scheduler
import (
"io"
"github.com/remind101/empire/pkg/runner"
"golang.org/x/net/context"
)
// AttachedRunner wraps a Manager to run attached processes using docker
// directly to get access to stdin and stdout.
type AttachedRunner struct {
Scheduler
Runner *runner.Runner
}
func (m *AttachedRunner) Run(ctx context.Context, app *App, p *Process, in io.Reader, out io.Writer) error {
// If an output stream is provided, run using the docker runner.
if out != nil {
return m.Runner.Run(ctx, runner.RunOpts{
Image: p.Image,
Command: p.Command,
Env: Env(app, p),
Memory: int64(p.MemoryLimit),
CPUShares: int64(p.CPUShares),
Labels: Labels(app, p),
Input: in,
Output: out,
})
}
return m.Scheduler.Run(ctx, app, p, in, out)
}