From f910be7c3490cce722b34b3830f836855f5dbddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Berrutti?= Date: Wed, 28 May 2025 15:54:51 +0100 Subject: [PATCH] Add signal exit-code option The change maintains backwards compatibility since the default value is still 1. Fix https://github.com/minio/sidekick/issues/130 --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 5463382..c2ef5e0 100644 --- a/main.go +++ b/main.go @@ -83,6 +83,7 @@ var ( globalHostBalance string globalTLSCert atomic.Pointer[[]byte] globalKeyPassword string + globalExitCode int ) const ( @@ -1075,6 +1076,7 @@ func sidekickMain(ctx *cli.Context) { globalHostBalance = "least" } globalKeyPassword = ctx.GlobalString("key-password") + globalExitCode = ctx.GlobalInt("exit-code") tlsMaxVersion := uint16(tls.VersionTLS13) switch tlsMax := ctx.GlobalString("tls-max"); tlsMax { @@ -1242,7 +1244,7 @@ func sidekickMain(ctx *cli.Context) { }) default: console.Infof("caught signal '%s'\n", signal) - os.Exit(1) + os.Exit(globalExitCode) } } } @@ -1381,6 +1383,11 @@ func main() { Value: "1.3", Hidden: true, }, + cli.IntFlag{ + Name: "exit-code", + Usage: "exit code to use when program terminates by a signal", + Value: 1, + }, } app.CustomAppHelpTemplate = `NAME: {{.Name}} - {{.Description}}