2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-01 18:55:13 +00:00
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
import "os"
|
|
|
|
|
2016-02-12 01:26:24 +00:00
|
|
|
type SignalTask struct {
|
2016-02-17 18:55:54 +00:00
|
|
|
baseTask
|
|
|
|
ID string
|
|
|
|
PID string
|
|
|
|
Signal os.Signal
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
func (s *Supervisor) signal(t *SignalTask) error {
|
|
|
|
i, ok := s.containers[t.ID]
|
2016-02-01 19:02:41 +00:00
|
|
|
if !ok {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
processes, err := i.container.Processes()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, p := range processes {
|
2016-02-17 18:55:54 +00:00
|
|
|
if p.ID() == t.PID {
|
|
|
|
return p.Signal(t.Signal)
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
2016-02-01 19:02:41 +00:00
|
|
|
}
|
2015-12-01 18:55:13 +00:00
|
|
|
return ErrProcessNotFound
|
|
|
|
}
|