Skip to content

Commit d25d361

Browse files
committed
Add signal exit-code option
1 parent 80c6e24 commit d25d361

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var (
8383
globalHostBalance string
8484
globalTLSCert atomic.Pointer[[]byte]
8585
globalKeyPassword string
86+
globalExitCode int
8687
)
8788

8889
const (
@@ -1075,6 +1076,7 @@ func sidekickMain(ctx *cli.Context) {
10751076
globalHostBalance = "least"
10761077
}
10771078
globalKeyPassword = ctx.GlobalString("key-password")
1079+
globalExitCode = ctx.GlobalInt("exit-code")
10781080

10791081
tlsMaxVersion := uint16(tls.VersionTLS13)
10801082
switch tlsMax := ctx.GlobalString("tls-max"); tlsMax {
@@ -1242,7 +1244,7 @@ func sidekickMain(ctx *cli.Context) {
12421244
})
12431245
default:
12441246
console.Infof("caught signal '%s'\n", signal)
1245-
os.Exit(1)
1247+
os.Exit(globalExitCode)
12461248
}
12471249
}
12481250
}
@@ -1381,6 +1383,11 @@ func main() {
13811383
Value: "1.3",
13821384
Hidden: true,
13831385
},
1386+
cli.IntFlag{
1387+
Name: "exit-code",
1388+
Usage: "exit code to use when program terminates",
1389+
Value: 1,
1390+
},
13841391
}
13851392
app.CustomAppHelpTemplate = `NAME:
13861393
{{.Name}} - {{.Description}}

0 commit comments

Comments
 (0)