Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command/run: add default GOMEMLIMIT #630

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/forwarder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func main() {
if _, err := maxprocs.Set(maxprocs.Logger(nil)); err != nil {
fmt.Fprintf(os.Stderr, "failed to set GOMAXPROCS: %v\n", err)
}
if _, ok := os.LookupEnv("GOMEMLIMIT"); !ok {
os.Setenv("GOMEMLIMIT", "250MiB")
}

if err := forwarder.Command().Execute(); err != nil {
os.WriteFile("/dev/termination-log", []byte(err.Error()), 0o644) //nolint // best effort
Expand Down
6 changes: 1 addition & 5 deletions command/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ func (c *command) runE(cmd *cobra.Command, _ []string) (cmdErr error) {
}()

logger.Infof("Forwarder %s (%s)", version.Version, version.Commit)
if limit, ok := os.LookupEnv("GOMEMLIMIT"); ok {
logger.Debugf("resource limits: GOMAXPROCS=%d GOMEMLIMIT=%s", runtime.GOMAXPROCS(0), limit)
} else {
logger.Debugf("resource limits: GOMAXPROCS=%d", runtime.GOMAXPROCS(0))
}
logger.Debugf("resource limits: GOMAXPROCS=%d GOMEMLIMIT=%s", runtime.GOMAXPROCS(0), os.Getenv("GOMEMLIMIT"))

var ep []forwarder.APIEndpoint

Expand Down