Skip to content

Commit 089607f

Browse files
authored
Add build time to help & first log. (#115)
1 parent cd3d78c commit 089607f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22

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

5-
go build -ldflags="-X 'main.Revision=$commit'" main/migration_verifier.go
6+
go build -ldflags="-X 'main.Revision=$commit' -X 'main.BuildTime=$buildTime'" main/migration_verifier.go

main/migration_verifier.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ const (
4242
ignoreReadConcernFlag = "ignoreReadConcern"
4343
configFileFlag = "configFile"
4444
pprofInterval = "pprofInterval"
45+
46+
buildVarDefaultStr = "Unknown; build with build.sh."
4547
)
4648

47-
// This gets set at build time.
48-
var Revision = "Unknown; build with build.sh."
49+
// These get set at build time, assuming use of build.sh.
50+
var Revision = buildVarDefaultStr
51+
var BuildTime = buildVarDefaultStr
4952

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

216219
v.GetLogger().Info().
217220
Str("revision", Revision).
221+
Str("buildTime", BuildTime).
218222
Int("processID", os.Getpid()).
219223
Msg("migration-verifier started.")
220224

0 commit comments

Comments
 (0)