Skip to content

Add build time to help & first log #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

commit=$(git show --no-patch --format='%H')
buildTime=$(date -u)

go build -ldflags="-X 'main.Revision=$commit'" main/migration_verifier.go
go build -ldflags="-X 'main.Revision=$commit' -X 'main.BuildTime=$buildTime'" main/migration_verifier.go
10 changes: 7 additions & 3 deletions main/migration_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ const (
ignoreReadConcernFlag = "ignoreReadConcern"
configFileFlag = "configFile"
pprofInterval = "pprofInterval"

buildVarDefaultStr = "Unknown; build with build.sh."
)

// This gets set at build time.
var Revision = "Unknown; build with build.sh."
// These get set at build time, assuming use of build.sh.
var Revision = buildVarDefaultStr
var BuildTime = buildVarDefaultStr

func main() {
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
Expand Down Expand Up @@ -165,7 +168,7 @@ func main() {
app := &cli.App{
Name: "migration-verifier",
Usage: "verify migration correctness",
Version: Revision,
Version: fmt.Sprintf("%s, built at %s", Revision, BuildTime),
Flags: flags,
Before: func(cCtx *cli.Context) error {
confFile := cCtx.String(configFileFlag)
Expand Down Expand Up @@ -215,6 +218,7 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err

v.GetLogger().Info().
Str("revision", Revision).
Str("buildTime", BuildTime).
Int("processID", os.Getpid()).
Msg("migration-verifier started.")

Expand Down