github.com/smithx10/nomad@v0.9.1-rc1/client/logmon/server.go (about)

     1  package logmon
     2  
     3  import (
     4  	"golang.org/x/net/context"
     5  
     6  	plugin "github.com/hashicorp/go-plugin"
     7  	"github.com/hashicorp/nomad/client/logmon/proto"
     8  )
     9  
    10  type logmonServer struct {
    11  	broker *plugin.GRPCBroker
    12  	impl   LogMon
    13  }
    14  
    15  func (s *logmonServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) {
    16  	cfg := &LogConfig{
    17  		LogDir:        req.LogDir,
    18  		StdoutLogFile: req.StdoutFileName,
    19  		StderrLogFile: req.StderrFileName,
    20  		MaxFiles:      int(req.MaxFiles),
    21  		MaxFileSizeMB: int(req.MaxFileSizeMb),
    22  		StdoutFifo:    req.StdoutFifo,
    23  		StderrFifo:    req.StderrFifo,
    24  	}
    25  
    26  	err := s.impl.Start(cfg)
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  	resp := &proto.StartResponse{}
    31  	return resp, nil
    32  }
    33  
    34  func (s *logmonServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) {
    35  	return &proto.StopResponse{}, s.impl.Stop()
    36  }