github.com/hernad/nomad@v1.6.112/drivers/docker/docklog/z_docker_logger_cmd.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package docklog 5 6 import ( 7 "os" 8 9 log "github.com/hashicorp/go-hclog" 10 plugin "github.com/hashicorp/go-plugin" 11 "github.com/hernad/nomad/plugins/base" 12 ) 13 14 // Install a plugin cli handler to ease working with tests 15 // and external plugins. 16 // This init() must be initialized last in package required by the child plugin 17 // process. It's recommended to avoid any other `init()` or inline any necessary calls 18 // here. See eeaa95d commit message for more details. 19 func init() { 20 if len(os.Args) > 1 && os.Args[1] == PluginName { 21 logger := log.New(&log.LoggerOptions{ 22 Level: log.Trace, 23 JSONFormat: true, 24 Name: PluginName, 25 }) 26 27 plugin.Serve(&plugin.ServeConfig{ 28 HandshakeConfig: base.Handshake, 29 Plugins: map[string]plugin.Plugin{ 30 PluginName: NewPlugin(NewDockerLogger(logger)), 31 }, 32 GRPCServer: plugin.DefaultGRPCServer, 33 Logger: logger, 34 }) 35 os.Exit(0) 36 } 37 }