2018-11-06 05:39:00 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2019-01-09 23:06:58 +00:00
|
|
|
log "github.com/hashicorp/go-hclog"
|
2018-11-06 05:39:00 +00:00
|
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
|
|
"github.com/hashicorp/nomad/drivers/docker/docklog"
|
|
|
|
"github.com/hashicorp/nomad/plugins/base"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DockerLoggerPluginCommand struct {
|
|
|
|
Meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *DockerLoggerPluginCommand) Help() string {
|
|
|
|
helpText := `
|
|
|
|
This is a command used by Nomad internally to launch the docker logger process"
|
|
|
|
`
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *DockerLoggerPluginCommand) Synopsis() string {
|
|
|
|
return "internal - launch a docker logger plugin"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *DockerLoggerPluginCommand) Run(args []string) int {
|
2019-01-09 23:06:58 +00:00
|
|
|
logger := log.New(&log.LoggerOptions{
|
|
|
|
Level: log.Trace,
|
|
|
|
JSONFormat: true,
|
|
|
|
Name: docklog.PluginName,
|
|
|
|
})
|
|
|
|
|
2018-11-06 05:39:00 +00:00
|
|
|
plugin.Serve(&plugin.ServeConfig{
|
|
|
|
HandshakeConfig: base.Handshake,
|
|
|
|
Plugins: map[string]plugin.Plugin{
|
2019-01-09 23:06:58 +00:00
|
|
|
docklog.PluginName: docklog.NewPlugin(docklog.NewDockerLogger(logger)),
|
2018-11-06 05:39:00 +00:00
|
|
|
},
|
|
|
|
GRPCServer: plugin.DefaultGRPCServer,
|
2019-01-09 23:06:58 +00:00
|
|
|
Logger: logger,
|
2018-11-06 05:39:00 +00:00
|
|
|
})
|
|
|
|
return 0
|
|
|
|
}
|