feat: add version output

This commit is contained in:
Zhiqiang Li
2023-04-04 14:48:33 +08:00
parent f64241aed7
commit 7351a8982d
3 changed files with 26 additions and 2 deletions

1
.gitignore vendored
View File

@@ -18,3 +18,4 @@
bin/
release/
docker-compose.yml
dist/

View File

@@ -25,7 +25,7 @@ var (
fallbackModelMapper = regexp.MustCompile(`[.:]`)
)
func init() {
func Init() {
AzureOpenAIAPIVer = os.Getenv(constant.ENV_AZURE_OPENAI_API_VER)
AzureOpenAIEndpoint = os.Getenv(constant.ENV_AZURE_OPENAI_ENDPOINT)

View File

@@ -2,6 +2,9 @@ package main
import (
"context"
"flag"
"fmt"
"github.com/stulzq/azure-openai-proxy/azure"
"log"
"net/http"
"os"
@@ -12,7 +15,16 @@ import (
"github.com/pkg/errors"
)
var (
version = ""
buildDate = ""
gitCommit = ""
)
func main() {
parseFlag()
azure.Init()
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
registerRoute(r)
@@ -43,3 +55,14 @@ func runServer(srv *http.Server) {
}
log.Println("Server exiting")
}
func parseFlag() {
ver := flag.Bool("v", false, "version")
flag.Parse()
if *ver {
fmt.Println("version:", version)
fmt.Println("buildDate:", buildDate)
fmt.Println("gitCommit:", gitCommit)
os.Exit(0)
}
}