storj/cmd/uplink/ulimit.go
Paul Willoughby 8efed4b270 cmd/uplink: raise fd limits
Change-Id: I507c92c38d45d3d2be3edee08b6b85552ae21c43
2022-04-27 18:11:44 +00:00

23 lines
482 B
Go

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build linux || darwin || freebsd
// +build linux darwin freebsd
package main
import "syscall"
// raise RLIMIT_NOFILE softlimit to hardlimit.
func raiseUlimits() {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return
}
if rLimit.Cur < rLimit.Max {
rLimit.Cur = rLimit.Max
_ = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
}
}