forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunix.go
More file actions
28 lines (20 loc) · 599 Bytes
/
unix.go
File metadata and controls
28 lines (20 loc) · 599 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//go:build linux || darwin
// +build linux darwin
package sysreq
import (
"fmt"
"context"
"golang.org/x/sys/unix"
)
func rlimitCheck(ctx context.Context) (problem, fix string, err error) {
const minLimit = 10000
var limit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &limit); err != nil {
return "", "", err
}
if limit.Cur < minLimit {
fix := fmt.Sprintf(`Please increase the open file limit by running "ulimit -n %[1]d" or adding --ulimit nofile=%[1]d:%[1]d to the docker run command"`, minLimit)
return "Insufficient file descriptor limit", fix, nil
}
return
}