Skip to content

Commit

Permalink
feat: add automaxprocs in the template
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jan 16, 2024
1 parent a36cef4 commit bc13c89
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,12 @@ type goModTemplateContext struct {
const mainModuleTemplate = `package main
import (
"go.uber.org/automaxprocs/maxprocs"
"go.uber.org/zap"
caddycmd "{{.CaddyModule}}/cmd"
"{{.CaddyModule}}"
// plug in Caddy modules here
_ "{{.CaddyModule}}/modules/standard"
{{- range .Plugins}}
Expand All @@ -363,6 +367,12 @@ import (
)
func main() {
undo, err := maxprocs.Set()
defer undo()
if err != nil {
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
}
caddycmd.Main()
}
`
Expand Down

0 comments on commit bc13c89

Please sign in to comment.