forked from hashicorp/nomad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
36 lines (30 loc) · 865 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package logmon
import (
"golang.org/x/net/context"
plugin "github.com/hashicorp/go-plugin"
"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()
}