mirror of
https://github.com/Kong/go-pluginserver.git
synced 2025-12-24 12:57:51 +08:00
feat(*) add version info
This commit is contained in:
6
Makefile
6
Makefile
@@ -1,8 +1,10 @@
|
||||
all=build
|
||||
BIN_NAME=go-pluginserver
|
||||
VERSION?=development
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
go build -ldflags="-s -w" -o $(BIN_NAME) -v
|
||||
go build -ldflags="-s -w -X main.version=$(VERSION)" -o $(BIN_NAME) -v
|
||||
|
||||
clean:
|
||||
rm -rf $(BIN_NAME)
|
||||
|
||||
23
main.go
23
main.go
@@ -4,17 +4,25 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"runtime"
|
||||
"github.com/ugorji/go/codec"
|
||||
"log"
|
||||
"net"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"reflect"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var kongPrefix = flag.String("kong-prefix", "/usr/local/kong", "Kong prefix path (specified by the -p argument commonly used in the kong cli)")
|
||||
var dump = flag.String("dump-plugin-info", "", "Dump info about `plugin` as a MessagePack object")
|
||||
var pluginsDir = flag.String("plugins-directory", "", "Set directory `path` where to search plugins")
|
||||
var version = "development"
|
||||
|
||||
/* flags */
|
||||
var (
|
||||
kongPrefix = flag.String("kong-prefix", "/usr/local/kong", "Kong prefix path (specified by the -p argument commonly used in the kong cli)")
|
||||
dump = flag.String("dump-plugin-info", "", "Dump info about `plugin` as a MessagePack object")
|
||||
pluginsDir = flag.String("plugins-directory", "", "Set directory `path` where to search plugins")
|
||||
showVersion = flag.Bool("version", false, "Print binary and runtime version")
|
||||
)
|
||||
|
||||
var socket string
|
||||
|
||||
@@ -28,6 +36,10 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func printVersion() {
|
||||
fmt.Printf("Version: %s\nRuntime Version: %s\n", version, runtime.Version())
|
||||
}
|
||||
|
||||
func dumpInfo() {
|
||||
s := newServer()
|
||||
|
||||
@@ -88,6 +100,11 @@ func startServer() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if *showVersion == true {
|
||||
printVersion()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *dump != "" {
|
||||
dumpInfo()
|
||||
os.Exit(0)
|
||||
|
||||
Reference in New Issue
Block a user