-
Notifications
You must be signed in to change notification settings - Fork 1
/
io.env.linux.go
56 lines (44 loc) · 1.05 KB
/
io.env.linux.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build linux
package elio
import (
"golang.org/x/sys/unix"
)
// GetMaxInCount get max in count
func GetMaxInCount(io string) (c int) {
c = DefaultPollInCount
if IoDefault.String() == io {
c = DefaultDefIOInCount
}
//AppInfo().Msgf("get.max.incount %d of model:'%s'", c, io)
return c
}
// GetCurrentIO get current io
func GetCurrentIO(io string) IOs {
if IoDefault.String() == io {
return IoDefault
}
return IoPoll
}
// GenIO gen io
func GenIO(io string) IoModel {
if IoDefault.String() == io {
AppInfo().Msgf("gen io.model:'%s'", IoDefault.String())
return NewIoDefault()
}
AppInfo().Msgf("gen io.model:%s'", IoPoll.String())
return NewIoPoll()
}
// SetLimit set limit
func SetLimit() (err error) {
var rLimit unix.Rlimit
if err = unix.Getrlimit(unix.RLIMIT_NOFILE, &rLimit); nil == err {
rLimit.Cur = rLimit.Max
if err = unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit); nil == err {
}
}
AppInfo().Msgf("set.limit set current limit:%d", rLimit.Cur)
if nil != err {
AppError().Err(err).Msgf("failed to set limit")
}
return err
}