github.com/bigcommerce/nomad@v0.9.3-bc/client/logmon/client.go (about) 1 package logmon 2 3 import ( 4 "context" 5 6 "github.com/hashicorp/nomad/client/logmon/proto" 7 "github.com/hashicorp/nomad/helper/pluginutils/grpcutils" 8 ) 9 10 type logmonClient struct { 11 client proto.LogMonClient 12 13 // doneCtx is closed when the plugin exits 14 doneCtx context.Context 15 } 16 17 func (c *logmonClient) Start(cfg *LogConfig) error { 18 req := &proto.StartRequest{ 19 LogDir: cfg.LogDir, 20 StdoutFileName: cfg.StdoutLogFile, 21 StderrFileName: cfg.StderrLogFile, 22 MaxFiles: uint32(cfg.MaxFiles), 23 MaxFileSizeMb: uint32(cfg.MaxFileSizeMB), 24 StdoutFifo: cfg.StdoutFifo, 25 StderrFifo: cfg.StderrFifo, 26 } 27 _, err := c.client.Start(context.Background(), req) 28 return grpcutils.HandleGrpcErr(err, c.doneCtx) 29 } 30 31 func (c *logmonClient) Stop() error { 32 req := &proto.StopRequest{} 33 _, err := c.client.Stop(context.Background(), req) 34 return grpcutils.HandleGrpcErr(err, c.doneCtx) 35 }