Skip to content

Commit

Permalink
feat: add version output
Browse files Browse the repository at this point in the history
  • Loading branch information
stulzq committed Apr 4, 2023
1 parent f64241a commit 7351a89
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
.idea/
bin/
release/
docker-compose.yml
docker-compose.yml
dist/
2 changes: 1 addition & 1 deletion azure/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 23 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package main

import (
"context"
"flag"
"fmt"
"github.com/stulzq/azure-openai-proxy/azure"
"log"
"net/http"
"os"
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 7351a89

Please sign in to comment.