Skip to content

Commit

Permalink
add debug and versioning information to server
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 19, 2020
1 parent 354efae commit 3d14686
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
22 changes: 17 additions & 5 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
)

var (
pwd string
pwd string
BuildVersion = ""
BuildCommit = ""
BuildDate = ""
BuiltBy = ""
)

func init() {
Expand Down Expand Up @@ -39,11 +43,19 @@ func Start(opts Options) error {
r.GET("/stats", func(c *gin.Context) {
_, err := os.Stat(pwd + "/profile.sav")
c.JSON(200, &struct {
Pwd string `json:"pwd"`
HasProfile bool `json:"hasProfile"`
Pwd string `json:"pwd"`
HasProfile bool `json:"hasProfile"`
BuildVersion string `json:"buildVersion"`
BuildCommit string `json:"buildCommit"`
BuildDate string `json:"buildDate"`
BuiltBy string `json:"builtBy"`
}{
Pwd: pwd,
HasProfile: err == nil && !os.IsNotExist(err),
Pwd: pwd,
HasProfile: err == nil && !os.IsNotExist(err),
BuildVersion: BuildVersion,
BuildCommit: BuildCommit,
BuildDate: BuildDate,
BuiltBy: BuiltBy,
})
})

Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ package main

import (
"github.com/cfi2017/bl3-save/cmd"
"github.com/cfi2017/bl3-save/internal/server"
"github.com/spf13/cobra"
)

var (
version = "v0.0.0-dev"
commit = ""
date = ""
builtBy = "local"
)

func main() {
server.BuildVersion = version
server.BuildCommit = commit
server.BuildDate = date
server.BuiltBy = builtBy
cobra.MousetrapHelpText = ""
cmd.Execute()
}

0 comments on commit 3d14686

Please sign in to comment.