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

Simplify/reduce ulimit info to file descriptors #383

Merged
merged 2 commits into from
Nov 17, 2021
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Unreleased changes are available as `avenga/couper:edge` container.
* **Added**
* Register `default` function as `coalesce` alias ([#356](https://github.com/avenga/couper/pull/356))
* New HCL function [`relative_url()`](./docs/REFERENCE.md#functions) ([#361](https://github.com/avenga/couper/pull/361))
* Log system resource limits at startup ([#334](https://github.com/avenga/couper/pull/334))
* Log file descriptor limit at startup ([#383](https://github.com/avenga/couper/pull/383))

* **Changed**
* [`server` block](./docs/REFERENCE.md#server-block) label is now optional, [`api` block](./docs/REFERENCE.md#api-block) may be labelled ([#358](https://github.com/avenga/couper/pull/358))
Expand Down
30 changes: 8 additions & 22 deletions command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,14 @@ func (a AcceptForwardedValue) Set(s string) error {
}

func (r *Run) Execute(args Args, config *config.Couper, logEntry *logrus.Entry) error {
rlimits := map[string]int{
"RLIMIT CPU": syscall.RLIMIT_CPU,
"RLIMIT Data": syscall.RLIMIT_DATA,
"RLIMIT CORE": syscall.RLIMIT_CORE,
"RLIMIT AS": syscall.RLIMIT_AS,
"RLIMIT Stack": syscall.RLIMIT_STACK,
"RLIMIT FSIZE": syscall.RLIMIT_FSIZE,
"RLIMIT Nofile": syscall.RLIMIT_NOFILE,
}
for key, value := range rlimits {
lim := syscall.Rlimit{}
err := syscall.Getrlimit(value, &lim)
if err != nil {
logEntry.Infof("an error occured while retrieving '%s'", key)
continue
}
if lim.Cur < 4096 {
logEntry.Warnf("%s Current: %d, %s Max: %d", key, lim.Cur, key, lim.Max)
continue
}
logEntry.Infof("%s Current: %d, %s Max: %d", key, lim.Cur, key, lim.Max)
lim := syscall.Rlimit{}
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
logEntry.Warnf("ulimit: error retrieving file descriptor limit")
} else {
logEntry.Infof("ulimit: max open files: %d (hard limit: %d)", lim.Cur, lim.Max)
}

r.settingsMu.Lock()
*r.settings = *config.Settings
r.settingsMu.Unlock()
Expand All @@ -131,7 +117,7 @@ func (r *Run) Execute(args Args, config *config.Couper, logEntry *logrus.Entry)

// Some remapping due to flag set pre-definition
env.Decode(r.settings)
err := r.settings.SetAcceptForwarded()
err = r.settings.SetAcceptForwarded()
if err != nil {
return err
}
Expand Down