Move supervisor to it's own package
It allows to keep main namespace cleaner Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
b296d50493
commit
69f8f566a2
24 changed files with 61 additions and 59 deletions
36
supervisor/add_process.go
Normal file
36
supervisor/add_process.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package supervisor
|
||||
|
||||
import "github.com/Sirupsen/logrus"
|
||||
|
||||
type AddProcessEvent struct {
|
||||
s *Supervisor
|
||||
}
|
||||
|
||||
// TODO: add this to worker for concurrent starts??? maybe not because of races where the container
|
||||
// could be stopped and removed...
|
||||
func (h *AddProcessEvent) Handle(e *Event) error {
|
||||
ci, ok := h.s.containers[e.ID]
|
||||
if !ok {
|
||||
return ErrContainerNotFound
|
||||
}
|
||||
p, io, err := h.s.runtime.StartProcess(ci.container, *e.Process, e.Console)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if e.Pid, err = p.Pid(); err != nil {
|
||||
return err
|
||||
}
|
||||
h.s.processes[e.Pid] = &containerInfo{
|
||||
container: ci.container,
|
||||
}
|
||||
l, err := h.s.copyIO(e.Stdin, e.Stdout, e.Stderr, io)
|
||||
if err != nil {
|
||||
// log the error but continue with the other commands
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"error": err,
|
||||
"id": e.ID,
|
||||
}).Error("log stdio")
|
||||
}
|
||||
h.s.processes[e.Pid].copier = l
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue