2018-09-24 18:37:45 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
|
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
|
|
"github.com/hashicorp/nomad/client/logmon"
|
|
|
|
"github.com/hashicorp/nomad/plugins/base"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LogMonPluginCommand struct {
|
|
|
|
Meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *LogMonPluginCommand) Help() string {
|
|
|
|
helpText := `
|
|
|
|
This is a command used by Nomad internally to launch the logmon process"
|
|
|
|
`
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *LogMonPluginCommand) Synopsis() string {
|
|
|
|
return "internal - launch a logmon plugin"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *LogMonPluginCommand) Run(args []string) int {
|
2019-01-05 00:08:47 +00:00
|
|
|
logger := hclog.New(&hclog.LoggerOptions{
|
|
|
|
Level: hclog.Trace,
|
|
|
|
JSONFormat: true,
|
|
|
|
Name: "logmon",
|
|
|
|
})
|
2018-09-24 18:37:45 +00:00
|
|
|
plugin.Serve(&plugin.ServeConfig{
|
|
|
|
HandshakeConfig: base.Handshake,
|
|
|
|
Plugins: map[string]plugin.Plugin{
|
2019-01-05 00:08:47 +00:00
|
|
|
"logmon": logmon.NewPlugin(logmon.NewLogMon(logger)),
|
2018-09-24 18:37:45 +00:00
|
|
|
},
|
|
|
|
GRPCServer: plugin.DefaultGRPCServer,
|
|
|
|
})
|
|
|
|
return 0
|
|
|
|
}
|