add JetBrains License Server Makefile

This commit is contained in:
ehlxr 2018-01-22 17:17:38 +08:00
parent 262e07e46f
commit 379c8cdb7b
2 changed files with 36 additions and 3 deletions

28
utils/idea/Makefile Normal file
View File

@ -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*

View File

@ -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)