Fix build on systems without syscall.Rlimit
On some systems (namely Windows), syscall.Rlimit is not defined, and
makes the build fail.
This fixes the build by making the rlimit calls only run on archs where
it is defined, defaulting to a stub on other systems.
See: 8427429c59
This commit is contained in:
parent
744c6e3f6d
commit
9647711921
@ -40,18 +40,6 @@ func (v *stringSliceFlag) Set(s string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func bumpOpenedFileLimit() error {
|
||||
var rlimit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||
return fmt.Errorf("failed to get RLIMIT_NOFILE: %v", err)
|
||||
}
|
||||
rlimit.Cur = rlimit.Max
|
||||
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||
return fmt.Errorf("failed to set RLIMIT_NOFILE: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
configPath string
|
||||
debug bool
|
||||
|
21
cmd/soju/rlimit.go
Normal file
21
cmd/soju/rlimit.go
Normal file
@ -0,0 +1,21 @@
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func bumpOpenedFileLimit() error {
|
||||
var rlimit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||
return fmt.Errorf("failed to get RLIMIT_NOFILE: %v", err)
|
||||
}
|
||||
rlimit.Cur = rlimit.Max
|
||||
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||
return fmt.Errorf("failed to set RLIMIT_NOFILE: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
8
cmd/soju/rlimit_stub.go
Normal file
8
cmd/soju/rlimit_stub.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
|
||||
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
|
||||
|
||||
package main
|
||||
|
||||
func bumpOpenedFileLimit() error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user