mirror of
https://github.com/caddyserver/caddy.git
synced 2025-03-24 21:05:16 +08:00
cmd: Promote undo maxProcs func to caller
Some checks are pending
Tests / test (./cmd/caddy/caddy, ~1.24.1, macos-14, 0, 1.24, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.24.1, ubuntu-latest, 0, 1.24, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.24.1, windows-latest, True, 1.24, windows) (push) Waiting to run
Tests / test (s390x on IBM Z) (push) Waiting to run
Tests / goreleaser-check (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, aix) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, darwin) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, dragonfly) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, freebsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, illumos) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, linux) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, netbsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, openbsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, solaris) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, windows) (push) Waiting to run
Lint / lint (macos-14, mac) (push) Waiting to run
Lint / lint (ubuntu-latest, linux) (push) Waiting to run
Lint / lint (windows-latest, windows) (push) Waiting to run
Lint / govulncheck (push) Waiting to run
Some checks are pending
Tests / test (./cmd/caddy/caddy, ~1.24.1, macos-14, 0, 1.24, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.24.1, ubuntu-latest, 0, 1.24, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.24.1, windows-latest, True, 1.24, windows) (push) Waiting to run
Tests / test (s390x on IBM Z) (push) Waiting to run
Tests / goreleaser-check (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, aix) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, darwin) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, dragonfly) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, freebsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, illumos) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, linux) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, netbsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, openbsd) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, solaris) (push) Waiting to run
Cross-Build / build (~1.24.1, 1.24, windows) (push) Waiting to run
Lint / lint (macos-14, mac) (push) Waiting to run
Lint / lint (ubuntu-latest, linux) (push) Waiting to run
Lint / lint (windows-latest, windows) (push) Waiting to run
Lint / govulncheck (push) Waiting to run
This commit is contained in:
parent
a686f7c346
commit
19876208c7
@ -172,7 +172,8 @@ func cmdRun(fl Flags) (int, error) {
|
||||
caddy.TrapSignals()
|
||||
|
||||
logger := caddy.Log()
|
||||
setResourceLimits(logger)
|
||||
undoMaxProcs := setResourceLimits(logger)
|
||||
defer undoMaxProcs()
|
||||
|
||||
configFlag := fl.String("config")
|
||||
configAdapterFlag := fl.String("adapter")
|
||||
|
@ -464,13 +464,12 @@ func printEnvironment() {
|
||||
}
|
||||
}
|
||||
|
||||
func setResourceLimits(logger *zap.Logger) {
|
||||
func setResourceLimits(logger *zap.Logger) func() {
|
||||
// Configure the maximum number of CPUs to use to match the Linux container quota (if any)
|
||||
// See https://pkg.go.dev/runtime#GOMAXPROCS
|
||||
undo, err := maxprocs.Set(maxprocs.Logger(logger.Sugar().Infof))
|
||||
defer undo()
|
||||
if err != nil {
|
||||
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
|
||||
logger.Warn("failed to set GOMAXPROCS", zap.Error(err))
|
||||
}
|
||||
|
||||
// Configure the maximum memory to use to match the Linux container quota (if any) or system memory
|
||||
@ -486,6 +485,8 @@ func setResourceLimits(logger *zap.Logger) {
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
return undo
|
||||
}
|
||||
|
||||
// StringSlice is a flag.Value that enables repeated use of a string flag.
|
||||
|
Loading…
x
Reference in New Issue
Block a user