2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-09-24 18:37:45 +00:00
|
|
|
package logmon
|
|
|
|
|
|
|
|
import (
|
2022-07-28 18:46:56 +00:00
|
|
|
"context"
|
2018-09-24 18:37:45 +00:00
|
|
|
|
2022-07-28 18:46:56 +00:00
|
|
|
"github.com/hashicorp/go-plugin"
|
2018-09-24 18:37:45 +00:00
|
|
|
"github.com/hashicorp/nomad/client/logmon/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
type logmonServer struct {
|
|
|
|
broker *plugin.GRPCBroker
|
|
|
|
impl LogMon
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *logmonServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) {
|
|
|
|
cfg := &LogConfig{
|
|
|
|
LogDir: req.LogDir,
|
|
|
|
StdoutLogFile: req.StdoutFileName,
|
|
|
|
StderrLogFile: req.StderrFileName,
|
|
|
|
MaxFiles: int(req.MaxFiles),
|
|
|
|
MaxFileSizeMB: int(req.MaxFileSizeMb),
|
|
|
|
StdoutFifo: req.StdoutFifo,
|
|
|
|
StderrFifo: req.StderrFifo,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := s.impl.Start(cfg)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
resp := &proto.StartResponse{}
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *logmonServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) {
|
|
|
|
return &proto.StopResponse{}, s.impl.Stop()
|
|
|
|
}
|