github.com/manicqin/nomad@v0.9.5/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  		FileExtension: req.FileExtension,
    25  	}
    26  
    27  	err := s.impl.Start(cfg)
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  	resp := &proto.StartResponse{}
    32  	return resp, nil
    33  }
    34  
    35  func (s *logmonServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) {
    36  	return &proto.StopResponse{}, s.impl.Stop()
    37  }