From 8f54cf5b44e4bda2a9730b7344b8b77903b21d4e Mon Sep 17 00:00:00 2001 From: a Date: Fri, 5 Dec 2025 16:02:02 -0600 Subject: [PATCH] this is an awful hack --- caddy.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/caddy.go b/caddy.go index c0d96fad0..abcb05a3c 100644 --- a/caddy.go +++ b/caddy.go @@ -750,13 +750,13 @@ func Validate(cfg *Config) error { // Errors are logged along the way, and an appropriate exit // code is emitted. func exitProcess(ctx context.Context, logger *zap.Logger) { - fmt.Println("exiting") + runningInTest := flag.Lookup("test.v") == nil && !strings.Contains(os.Args[0], ".test") // let the rest of the program know we're quitting; only do it once - if !atomic.CompareAndSwapInt32(exiting, 0, 1) { - fmt.Println("earlly exiting") - return + if !runningInTest { + if !atomic.CompareAndSwapInt32(exiting, 0, 1) { + return + } } - fmt.Println("doing exiting") // give the OS or service/process manager our 2 weeks' notice: we quit if err := notify.Stopping(); err != nil { @@ -814,7 +814,7 @@ func exitProcess(ctx context.Context, logger *zap.Logger) { logger.Error("unclean shutdown") } // check if we are in test environment, and dont call exit if we are - if flag.Lookup("test.v") == nil && !strings.Contains(os.Args[0], ".test") { + if runningInTest { os.Exit(exitCode) } }()