add fileserver version info

This commit is contained in:
s_jqzhang 2019-05-14 11:33:08 +08:00
parent 9b8871c2c1
commit 6c3f4d4f39
2 changed files with 20 additions and 0 deletions

9
build.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
BIN_VERSION="go-fastdfs:${1-not set}"
go build -ldflags "-w -s -X 'main.VERSION=$BIN_VERSION' -X 'main.BUILD_TIME=build_time:`date`' -X 'main.GO_VERSION=`go version`' -X 'main.GIT_VERSION=git_version:`git rev-parse HEAD`'" fileserver.go
GOOS=windows go build -ldflags "-w -s -X 'main.VERSION=$BIN_VERSION' -X 'main.BUILD_TIME=build_time:`date`' -X 'main.GO_VERSION=`go version`' -X 'main.GIT_VERSION=git_version:`git rev-parse HEAD`'" fileserver.go

View File

@ -53,6 +53,13 @@ var server *Server
var logacc log.LoggerInterface
var FOLDERS = []string{DATA_DIR, STORE_DIR, CONF_DIR, STATIC_DIR}
var CONST_QUEUE_SIZE = 10000
var (
VERSION string
BUILD_TIME string
GO_VERSION string
GIT_VERSION string
v = flag.Bool("v", false, "display version")
)
var (
FileName string
ptr unsafe.Pointer
@ -3599,6 +3606,10 @@ func (HttpHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
http.DefaultServeMux.ServeHTTP(res, req)
}
func (this *Server) Main() {
if *v {
fmt.Printf("%s\n%s\n%s\n%s\n", VERSION, BUILD_TIME, GO_VERSION,GIT_VERSION)
return
}
go func() {
for {
this.CheckFileAndSendToPeer(this.util.GetToDay(), CONST_Md5_ERROR_FILE_NAME, false)