mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
refactor: move automaxprocs init in caddycmd.Main()
This commit is contained in:
parent
d9aded016c
commit
dba556fe4b
2 changed files with 7 additions and 10 deletions
|
@ -29,22 +29,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.uber.org/automaxprocs/maxprocs"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
|
|
||||||
caddycmd "github.com/caddyserver/caddy/v2/cmd"
|
caddycmd "github.com/caddyserver/caddy/v2/cmd"
|
||||||
|
|
||||||
"github.com/caddyserver/caddy/v2"
|
|
||||||
// plug in Caddy modules here
|
// plug in Caddy modules here
|
||||||
_ "github.com/caddyserver/caddy/v2/modules/standard"
|
_ "github.com/caddyserver/caddy/v2/modules/standard"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
undo, err := maxprocs.Set()
|
|
||||||
defer undo()
|
|
||||||
if err != nil {
|
|
||||||
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
caddycmd.Main()
|
caddycmd.Main()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import (
|
||||||
|
|
||||||
"github.com/caddyserver/certmagic"
|
"github.com/caddyserver/certmagic"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
"go.uber.org/automaxprocs/maxprocs"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/caddyserver/caddy/v2"
|
"github.com/caddyserver/caddy/v2"
|
||||||
|
@ -64,6 +65,12 @@ func Main() {
|
||||||
os.Exit(caddy.ExitCodeFailedStartup)
|
os.Exit(caddy.ExitCodeFailedStartup)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
undo, err := maxprocs.Set()
|
||||||
|
defer undo()
|
||||||
|
if err != nil {
|
||||||
|
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
|
||||||
|
}
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
var exitError *exitError
|
var exitError *exitError
|
||||||
if errors.As(err, &exitError) {
|
if errors.As(err, &exitError) {
|
||||||
|
|
Loading…
Reference in a new issue