1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00
This commit is contained in:
a 2024-06-18 20:11:56 -05:00
parent 01cb878087
commit b491fc5d6c
No known key found for this signature in database
GPG key ID: 374BC539FE795AF0
2 changed files with 8 additions and 2 deletions

View file

@ -780,7 +780,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 flag.Lookup("test.v") == nil && !strings.Contains(os.Args[0], ".test") {
os.Exit(exitCode)
}
}()

View file

@ -20,6 +20,7 @@ import (
"crypto/rand"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"io/fs"
@ -257,6 +258,7 @@ func cmdRun(fl Flags) (int, error) {
// if enabled, reload config file automatically on changes
// (this better only be used in dev!)
// do not enable this during tests, it will cause leaks
if watchFlag {
go watchConfigFile(configFile, configAdapterFlag)
}
@ -280,7 +282,11 @@ func cmdRun(fl Flags) (int, error) {
}
}
if flag.Lookup("test.v") == nil || !strings.Contains(os.Args[0], ".test") {
return caddy.ExitCodeSuccess, nil
} else {
select {}
}
}
func cmdStop(fl Flags) (int, error) {