cmd/uplink: raise fd limits

Change-Id: I507c92c38d45d3d2be3edee08b6b85552ae21c43
This commit is contained in:
Paul Willoughby 2022-04-26 15:07:33 -06:00 committed by JT Olio
parent 5cebbdee03
commit 8efed4b270
3 changed files with 34 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import (
func main() {
ex := newExternal()
raiseUlimits()
ok, err := clingy.Environment{
Name: "uplink",
Args: os.Args[1:],

22
cmd/uplink/ulimit.go Normal file
View File

@ -0,0 +1,22 @@
// 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)
}
}

View File

@ -0,0 +1,11 @@
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build !linux && !darwin && !freebsd
// +build !linux,!darwin,!freebsd
package main
func raiseUlimits() {
return
}