92 lines
2.2 KiB
Go
92 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
|
|
_ "git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/controllers"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
_ "git.rosy.net.cn/jx-callback/globals/api"
|
|
"git.rosy.net.cn/jx-callback/globals/beegodb"
|
|
_ "git.rosy.net.cn/jx-callback/routers"
|
|
beego "github.com/astaxie/beego/server/web"
|
|
_ "net/http/pprof"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
GitCommit string
|
|
GitBranch string
|
|
GitState string
|
|
GitSummary string
|
|
BuildDate string
|
|
Version string
|
|
)
|
|
|
|
func Init() {
|
|
beegodb.Init()
|
|
|
|
buildTime, err := time.ParseInLocation(time.RFC3339, BuildDate, time.UTC)
|
|
if err == nil {
|
|
buildTime = buildTime.Local()
|
|
}
|
|
cms.InitServiceInfo(Version, buildTime, GitCommit)
|
|
misc.Init()
|
|
controllers.Init()
|
|
}
|
|
|
|
// 返回true表示非运行服务
|
|
func checkCmdFlags() bool {
|
|
var flagGitCommit bool
|
|
var flagGitBranch bool
|
|
var flagGitState bool
|
|
var flagGitSummary bool
|
|
var flagBuildDate bool
|
|
var flagVersion bool
|
|
var flagFullInfo bool
|
|
|
|
flag.BoolVar(&flagGitCommit, "gitcommit", false, "get gitcommit info")
|
|
flag.BoolVar(&flagGitBranch, "gitbranch", false, "get gitbranch info")
|
|
flag.BoolVar(&flagGitState, "gitstate", false, "get gitstate info")
|
|
flag.BoolVar(&flagGitSummary, "gitsummary", false, "get gitsummary info")
|
|
flag.BoolVar(&flagBuildDate, "builddate", false, "get builddate info")
|
|
flag.BoolVar(&flagVersion, "version", false, "get version info")
|
|
flag.BoolVar(&flagFullInfo, "fullinfo", false, "get fullinfo info")
|
|
flag.Parse()
|
|
|
|
if flagGitCommit || flagFullInfo {
|
|
fmt.Println(GitCommit)
|
|
}
|
|
if flagGitBranch || flagFullInfo {
|
|
fmt.Println(GitBranch)
|
|
}
|
|
if flagGitState || flagFullInfo {
|
|
fmt.Println(GitState)
|
|
}
|
|
if flagGitSummary || flagFullInfo {
|
|
fmt.Println(GitSummary)
|
|
}
|
|
if flagBuildDate || flagFullInfo {
|
|
fmt.Println(BuildDate)
|
|
}
|
|
if flagVersion || flagFullInfo {
|
|
fmt.Println(Version)
|
|
}
|
|
|
|
return len(os.Args) > 1
|
|
}
|
|
|
|
func main() {
|
|
Init()
|
|
globals.SugarLogger.Debug("====================================api")
|
|
//先打开swagger
|
|
//if beego.BConfig.RunMode != "prod" {
|
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
|
//}
|
|
beego.Run()
|
|
}
|