From 379c8cdb7bbe8c71c31dc7e64b23ec386a737827 Mon Sep 17 00:00:00 2001 From: ehlxr Date: Mon, 22 Jan 2018 17:17:38 +0800 Subject: [PATCH] add JetBrains License Server Makefile --- utils/idea/Makefile | 28 ++++++++++++++++++++++++++++ utils/idea/main.go | 11 ++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 utils/idea/Makefile diff --git a/utils/idea/Makefile b/utils/idea/Makefile new file mode 100644 index 0000000..7b3cfd4 --- /dev/null +++ b/utils/idea/Makefile @@ -0,0 +1,28 @@ +GOOS := $(shell go env | awk -F= '$$1=="GOOS" {print $$2}' | awk -F '"' '{print $$2}') # 此处 awk 需使用两个 $ +GOARCH := $(shell go env | awk -F= '$$1=="GOARCH" {print $$2}' | awk -F '"' '{print $$2}') + +.PHONY: build +build: + @go build -ldflags "-s -w" -o JetBrainsLicenseServer_$(GOOS)_$(GOARCH) + @upx JetBrainsLicenseServer_$(GOOS)_$(GOARCH) + +.PHONY: amd64 +amd64: + @CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o JetBrainsLicenseServer_darwin_amd64 + @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o JetBrainsLicenseServer_linux_amd64 + @CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o JetBrainsLicenseServer_windows_amd64.exe + +.PHONY: 386 +386: + @CGO_ENABLED=0 GOOS=darwin GOARCH=386 go build -ldflags "-s -w" -o JetBrainsLicenseServer_darwin_386 + @CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w" -o JetBrainsLicenseServer_linux_386 + @CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w" -o JetBrainsLicenseServer_windows_386.exe + +.PHONY: clean +clean: + @rm -rf JetBrainsLicenseServer* idea + +# 压缩。需要安装 https://github.com/upx/upx +.PHONY: upx +upx: + @upx JetBrainsLicenseServer* \ No newline at end of file diff --git a/utils/idea/main.go b/utils/idea/main.go index 3fbe27c..cbb36de 100755 --- a/utils/idea/main.go +++ b/utils/idea/main.go @@ -20,8 +20,8 @@ import ( func main() { log.SetOutput(os.Stdout) - port := flag.Int("p", 1017, "port") - host := flag.String("host", "0.0.0.0", "Bind TCP Address") + port := flag.Int("p", 21017, "port") + host := flag.String("h", "0.0.0.0", "Bind TCP Address") flag.Parse() addr := fmt.Sprintf("%s:%d", *host, *port) @@ -29,7 +29,12 @@ func main() { addr = strings.Replace(addr, "0.0.0.0", "127.0.0.1", 1) } - log.Println("Starting server at http://" + addr) + log.Println("************************************************************") + log.Printf("** %-55s**", "JetBrains License Server") + log.Printf("** %-55s**", "Please support genuine!!!") + log.Printf("** listen on %-45s**", fmt.Sprintf("%s:%d...", *host, *port)) + log.Printf("** You can use %-43s**", fmt.Sprintf("http://%s as license server", addr)) + log.Println("************************************************************") routerBinding() err := http.ListenAndServe(addr, http.DefaultServeMux)