mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
Make limits into a pkg.
This is so that we can use the in other utils. debated with davec
This commit is contained in:
parent
dd7c910e86
commit
d00ccc0d3c
5 changed files with 15 additions and 7 deletions
3
btcd.go
3
btcd.go
|
@ -5,6 +5,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/conformal/btcd/limits"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -128,7 +129,7 @@ func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
// Up some limits.
|
// Up some limits.
|
||||||
if err := setLimits(); err != nil {
|
if err := limits.SetLimits(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package limits
|
||||||
|
|
||||||
// Plan 9 has no process accounting. no-op here
|
// Plan 9 has no process accounting. no-op here
|
||||||
func setLimits() error {
|
func SetLimits() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// +build !windows,!plan9
|
// +build !windows,!plan9
|
||||||
|
|
||||||
package main
|
package limits
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -16,7 +16,7 @@ const (
|
||||||
fileLimitMin = 1024
|
fileLimitMin = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
func setLimits() error {
|
func SetLimits() error {
|
||||||
var rLimit syscall.Rlimit
|
var rLimit syscall.Rlimit
|
||||||
|
|
||||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package limits
|
||||||
|
|
||||||
func setLimits() error {
|
func SetLimits() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/conformal/btcd/limits"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
_ "github.com/conformal/btcdb/ldb"
|
_ "github.com/conformal/btcdb/ldb"
|
||||||
"github.com/conformal/btclog"
|
"github.com/conformal/btclog"
|
||||||
|
@ -66,8 +67,14 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use all processor cores.
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
|
// Up some limits.
|
||||||
|
if err := limits.SetLimits(); err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
backendLogger := btclog.NewDefaultBackendLogger()
|
backendLogger := btclog.NewDefaultBackendLogger()
|
||||||
defer backendLogger.Flush()
|
defer backendLogger.Flush()
|
||||||
log = btclog.NewSubsystemLogger(backendLogger, "")
|
log = btclog.NewSubsystemLogger(backendLogger, "")
|
||||||
|
|
Loading…
Add table
Reference in a new issue