mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
Platform sanity checks (#2271)
* Platform sanity checks * Don't yell about `root` because Docker
This commit is contained in:
parent
507a8e6773
commit
01d71a767d
@ -100,6 +100,7 @@ const (
|
||||
// The componentName is used for logging purposes, and should be a friendly name
|
||||
// of the compontent running, e.g. "SyncAPI"
|
||||
func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...BaseDendriteOptions) *BaseDendrite {
|
||||
platformSanityChecks()
|
||||
useHTTPAPIs := false
|
||||
cacheMetrics := true
|
||||
for _, opt := range options {
|
||||
|
8
setup/base/sanity_other.go
Normal file
8
setup/base/sanity_other.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build !linux && !darwin && !netbsd && !freebsd && !openbsd && !solaris && !dragonfly && !aix
|
||||
// +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!solaris,!dragonfly,!aix
|
||||
|
||||
package base
|
||||
|
||||
func platformSanityChecks() {
|
||||
// Nothing to do yet.
|
||||
}
|
22
setup/base/sanity_unix.go
Normal file
22
setup/base/sanity_unix.go
Normal file
@ -0,0 +1,22 @@
|
||||
//go:build linux || darwin || netbsd || freebsd || openbsd || solaris || dragonfly || aix
|
||||
// +build linux darwin netbsd freebsd openbsd solaris dragonfly aix
|
||||
|
||||
package base
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func platformSanityChecks() {
|
||||
// Dendrite needs a relatively high number of file descriptors in order
|
||||
// to function properly, particularly when federating with lots of servers.
|
||||
// If we run out of file descriptors, we might run into problems accessing
|
||||
// PostgreSQL amongst other things. Complain at startup if we think the
|
||||
// number of file descriptors is too low.
|
||||
var rLimit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err == nil && rLimit.Cur < 65535 {
|
||||
logrus.Warnf("IMPORTANT: Process file descriptor limit is currently %d, it is recommended to raise the limit for Dendrite to at least 65535 to avoid issues", rLimit.Cur)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user