Skip to content
Snippets Groups Projects
Commit 43e7d75b authored by gbe's avatar gbe
Browse files

Log commit and build time on start

parent f72f1182
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,9 @@ test:
build:
stage: build
script:
- GOOS=freebsd go build -o invinoveritas
- commitHash=$(git rev-parse HEAD)
- now=$(date +%Y-%m-%d-%T)
- GOOS=freebsd go build -trimpath -tags "netgo osusergo timetzdata" -ldflags "-X main.commitHash=$commitHash -X main.buildTime=$now" -o invinoveritas
artifacts:
paths:
- invinoveritas
......
run:
find . -name '*.go' -or -name '*.tpl' -or -path 'static/*' | entr -d -r go run . -debug
find . -name '*.go' -or -name '*.tpl' -or -path 'static/*' | \
entr -d -r \
go run -ldflags "-X main.commitHash=$(shell git rev-parse HEAD) -X main.buildTime=$(shell /bin/date +%Y-%m-%d-%T)" . -debug
......@@ -26,6 +26,12 @@ var templateFS embed.FS
//go:embed static/*
var staticFS embed.FS
// Build info. Will be set by Gitlab pipeline.
var (
commitHash string
buildTime string
)
func httpError(w http.ResponseWriter, r *http.Request, msg string, err error, status int) {
if err != nil {
msg += ": " + err.Error()
......@@ -128,6 +134,9 @@ func main() {
logger = level.NewFilter(logger, filter)
level.Info(logger).
Log("commit_hash", commitHash, "buildTime", buildTime)
db, err := openDB(*dbPath, logger)
if err != nil {
logger.Log("error", err, "msg", "can't open DB")
......@@ -140,9 +149,9 @@ func main() {
err = initDB(ctx, db)
if err != nil {
logger.Log("wal_name", ql.WalName(*dbPath+".ql"),
"error", err,
"msg", "can't initalize DB")
level.Error(logger).
Log("wal_name", ql.WalName(*dbPath+".ql"),
"error", err, "msg", "can't initalize DB")
os.Exit(1)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment