3b5e72913e
I spent some time today on my local Mac to figure out why Consul 1.6.3+ was not accepting limits.http_max_conns_per_client. This adds an explicit check on number of file descriptors to be sure it might work (this is no guarantee as if many clients are reaching the agent, it might consume even more file descriptors) Anyway, many users are fighting with RLIMIT_NOFILE, having a clear message would allow them to figure out what to fix. Example of message (reload or start): ``` 2020-03-11T16:38:37.062+0100 [ERROR] agent: Error starting agent: error="system allows a max of 512 file descriptors, but limits.http_max_conns_per_client: 8192 needs at least 8212" ```
14 lines
320 B
Go
14 lines
320 B
Go
// +build !windows
|
|
|
|
package config
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
// getrlimit return the max file descriptors allocated by system
|
|
// return the number of file descriptors max
|
|
func getrlimit() (uint64, error) {
|
|
var limit unix.Rlimit
|
|
err := unix.Getrlimit(unix.RLIMIT_NOFILE, &limit)
|
|
return uint64(limit.Cur), err
|
|
}
|