Skip to content

Commit

Permalink
exclude rlimit code for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Apr 16, 2022
1 parent 8596be2 commit 1d205b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
15 changes: 1 addition & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func main() {
log.Fatalf("failed to initialize Zap logger: %v", err)
}

err = updateRLimit(logger)
err = utils.UpdateRLimit(logger)
if err != nil {
logger.Warn("failed to increase rlimit", zap.Error(err))
}
Expand All @@ -101,19 +101,6 @@ func main() {
job.NewRunner(runnerConfigOptions, jobsGlobalConfig).Run(ctx, logger)
}

func updateRLimit(logger *zap.Logger) error {
var rLimit syscall.Rlimit

err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return err
}

rLimit.Cur = rLimit.Max

return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
}

func newZapLogger(debug bool) (*zap.Logger, error) {
if debug {
return zap.NewDevelopment()
Expand Down
22 changes: 22 additions & 0 deletions src/utils/utils_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build !windows
// +build !windows

package utils

import (
"go.uber.org/zap"
sys "golang.org/x/sys/unix"
)

func UpdateRLimit(logger *zap.Logger) error {
var rLimit sys.Rlimit

err := sys.Getrlimit(sys.RLIMIT_NOFILE, &rLimit)
if err != nil {
return err
}

rLimit.Cur = rLimit.Max

return sys.Setrlimit(sys.RLIMIT_NOFILE, &rLimit)
}
9 changes: 9 additions & 0 deletions src/utils/utils_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package utils

import (
"go.uber.org/zap"
)

func UpdateRLimit(logger *zap.Logger) error {
return nil
}

0 comments on commit 1d205b8

Please sign in to comment.