Skip to content

Commit

Permalink
update soft rlimit to hard value
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Apr 16, 2022
1 parent 93c189e commit 8596be2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func main() {
log.Fatalf("failed to initialize Zap logger: %v", err)
}

err = updateRLimit(logger)
if err != nil {
logger.Warn("failed to increase rlimit", zap.Error(err))
}

go ota.WatchUpdates(otaConfig)
setUpPprof(*pprof, *debug)
rand.Seed(time.Now().UnixNano())
Expand All @@ -92,13 +97,21 @@ func main() {

metrics.InitOrFail(ctx, logger, *prometheusOn, *prometheusPushGateways, jobsGlobalConfig.ClientID, country)

r, err := job.NewRunner(runnerConfigOptions, jobsGlobalConfig)
go cancelOnSignal(cancel)
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 {
log.Panicf("Error initializing runner: %v", err)
return err
}

go cancelOnSignal(cancel)
r.Run(ctx, logger)
rLimit.Cur = rLimit.Max

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

func newZapLogger(debug bool) (*zap.Logger, error) {
Expand Down
4 changes: 2 additions & 2 deletions src/job/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ type Runner struct {
}

// NewRunner according to the config
func NewRunner(cfgOptions *ConfigOptions, globalJobsCfg *GlobalConfig) (*Runner, error) {
func NewRunner(cfgOptions *ConfigOptions, globalJobsCfg *GlobalConfig) *Runner {
return &Runner{
cfgOptions: cfgOptions,
globalJobsCfg: globalJobsCfg,
}, nil
}
}

// Run the runner and block until Stop() is called
Expand Down

0 comments on commit 8596be2

Please sign in to comment.