Created
January 18, 2021 09:55
-
-
Save abserari/4ad8d6954119af97d876a575012570c9 to your computer and use it in GitHub Desktop.
Update system limit about file number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package maxopenfile | |
import ( | |
"log" | |
"syscall" | |
) | |
func MaxOpenFiles() { | |
var rLimit syscall.Rlimit | |
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) | |
if err != nil { | |
log.Println("Error Getting Rlimit ", err) | |
} | |
if rLimit.Cur < rLimit.Max { | |
rLimit.Cur = rLimit.Max | |
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) | |
if err != nil { | |
log.Println("Error Setting Rlimit ", err) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment