Skip to content

Commit 87e8e2b

Browse files
committed
set resource limits
1 parent 734d3e7 commit 87e8e2b

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.10.0] - 2020-03-18
8+
### Changed
9+
- Set resource limit
10+
711
## [0.9.0] - 2020-02-15
812
### Changed
913
- Router implementation refactoring

app/app.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"os/signal"
1818
"path/filepath"
19+
"runtime"
1920
"strconv"
2021
"syscall"
2122
"time"
@@ -38,6 +39,8 @@ import (
3839
const (
3940
envAllocationID = "JACKAL_ALLOCATION_ID"
4041

42+
darwinOpenMax = 10240
43+
4144
defaultShutDownWaitTime = time.Duration(5) * time.Second
4245
)
4346

@@ -181,6 +184,9 @@ func (a *Application) Run() error {
181184
a.comps = component.New(&cfg.Components, a.mods.DiscoInfo)
182185

183186
// start serving s2s...
187+
if err := a.setRLimit(); err != nil {
188+
return err
189+
}
184190
if cfg.S2S != nil {
185191
a.s2s = s2s.New(cfg.S2S, a.mods, a.s2sOutProvider, a.router)
186192
a.s2s.Start()
@@ -260,6 +266,26 @@ func (a *Application) printLogo(allocID string) {
260266
log.Infof("jackal %v - allocation_id: %s\n", version.ApplicationVersion, allocID)
261267
}
262268

269+
func (a *Application) setRLimit() error {
270+
var rLim syscall.Rlimit
271+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLim); err != nil {
272+
return err
273+
}
274+
if rLim.Cur < rLim.Max {
275+
switch runtime.GOOS {
276+
case "darwin":
277+
// The max file limit is 10240, even though
278+
// the max returned by Getrlimit is 1<<63-1.
279+
// This is OPEN_MAX in sys/syslimits.h.
280+
rLim.Cur = darwinOpenMax
281+
default:
282+
rLim.Cur = rLim.Max
283+
}
284+
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLim)
285+
}
286+
return nil
287+
}
288+
263289
func (a *Application) initDebugServer(port int) error {
264290
a.debugSrv = &http.Server{}
265291
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ require (
1515
github.com/sony/gobreaker v0.4.1
1616
github.com/stretchr/testify v1.3.0
1717
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
18-
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
1918
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
2019
golang.org/x/text v0.3.0
21-
golang.org/x/tools v0.0.0-20200312194400-c312e98713c2 // indirect
2220
google.golang.org/appengine v1.3.0 // indirect
2321
gopkg.in/yaml.v2 v2.2.7
2422
)

go.sum

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,17 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
3333
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
3434
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
3535
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
36-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
3736
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3837
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
3938
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
40-
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
41-
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
42-
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
43-
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
44-
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
4539
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
4640
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
47-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
48-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
4941
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
5042
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
51-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
52-
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5343
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5444
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5545
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
5646
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
57-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
58-
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
59-
golang.org/x/tools v0.0.0-20200312194400-c312e98713c2 h1:6TB4+MaZlkcSsJDu+BS5yxSEuZIYhjWz+jhbSLEZylI=
60-
golang.org/x/tools v0.0.0-20200312194400-c312e98713c2/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
61-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
62-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
63-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
64-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6547
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
6648
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
6749
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// ApplicationVersion represents application version.
13-
var ApplicationVersion = NewVersion(0, 9, 0)
13+
var ApplicationVersion = NewVersion(0, 10, 0)
1414

1515
// SemanticVersion represents version information with Semantic Versioning specifications.
1616
type SemanticVersion struct {

0 commit comments

Comments
 (0)