Port over supervisor to use grpc shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
e1eeb40d1d
commit
f187da9485
13 changed files with 811 additions and 497 deletions
|
@ -120,6 +120,14 @@ func (p *initProcess) Resize(ws console.WinSize) error {
|
|||
return p.console.Resize(ws)
|
||||
}
|
||||
|
||||
func (p *initProcess) Pause(context context.Context) error {
|
||||
return p.runc.Pause(context, p.id)
|
||||
}
|
||||
|
||||
func (p *initProcess) Resume(context context.Context) error {
|
||||
return p.runc.Resume(context, p.id)
|
||||
}
|
||||
|
||||
func (p *initProcess) killAll(context context.Context) error {
|
||||
return p.runc.Kill(context, p.id, int(syscall.SIGKILL), &runc.KillOpts{
|
||||
All: true,
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
|
||||
var emptyResponse = &google_protobuf.Empty{}
|
||||
|
||||
// NewService returns a new shim service that can be used via GRPC
|
||||
func NewService() *Service {
|
||||
// New returns a new shim service that can be used via GRPC
|
||||
func New() *Service {
|
||||
return &Service{
|
||||
processes: make(map[int]process),
|
||||
events: make(chan *apishim.Event, 4096),
|
||||
|
@ -43,7 +43,7 @@ func (s *Service) Create(ctx context.Context, r *apishim.CreateRequest) (*apishi
|
|||
s.id = r.ID
|
||||
s.mu.Unlock()
|
||||
s.events <- &apishim.Event{
|
||||
Type: apishim.EventType_CREATED,
|
||||
Type: apishim.EventType_CREATE,
|
||||
ID: r.ID,
|
||||
Pid: uint32(pid),
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func (s *Service) Start(ctx context.Context, r *apishim.StartRequest) (*google_p
|
|||
return nil, err
|
||||
}
|
||||
s.events <- &apishim.Event{
|
||||
Type: apishim.EventType_STARTED,
|
||||
Type: apishim.EventType_START,
|
||||
ID: s.id,
|
||||
Pid: uint32(s.initProcess.Pid()),
|
||||
}
|
||||
|
@ -154,6 +154,20 @@ func (s *Service) State(ctx context.Context, r *apishim.StateRequest) (*apishim.
|
|||
return o, nil
|
||||
}
|
||||
|
||||
func (s *Service) Pause(ctx context.Context, r *apishim.PauseRequest) (*google_protobuf.Empty, error) {
|
||||
if err := s.initProcess.Pause(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return emptyResponse, nil
|
||||
}
|
||||
|
||||
func (s *Service) Resume(ctx context.Context, r *apishim.ResumeRequest) (*google_protobuf.Empty, error) {
|
||||
if err := s.initProcess.Resume(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return emptyResponse, nil
|
||||
}
|
||||
|
||||
func (s *Service) ProcessExit(e utils.Exit) error {
|
||||
s.mu.Lock()
|
||||
if p, ok := s.processes[e.Pid]; ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue