Make limits into a pkg.

This is so that we can use the in other utils.

debated with davec
This commit is contained in:
Marco Peereboom 2014-01-07 15:30:25 -06:00 committed by Dave Collins
parent dd7c910e86
commit d00ccc0d3c
5 changed files with 15 additions and 7 deletions

View file

@ -5,6 +5,7 @@
package main
import (
"github.com/conformal/btcd/limits"
"fmt"
"net"
"net/http"
@ -128,7 +129,7 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
// Up some limits.
if err := setLimits(); err != nil {
if err := limits.SetLimits(); err != nil {
os.Exit(1)
}

View file

@ -2,9 +2,9 @@
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
package limits
// Plan 9 has no process accounting. no-op here
func setLimits() error {
func SetLimits() error {
return nil
}

View file

@ -4,7 +4,7 @@
// +build !windows,!plan9
package main
package limits
import (
"fmt"
@ -16,7 +16,7 @@ const (
fileLimitMin = 1024
)
func setLimits() error {
func SetLimits() error {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
package limits
func setLimits() error {
func SetLimits() error {
return nil
}

View file

@ -7,6 +7,7 @@ package main
import (
"encoding/binary"
"fmt"
"github.com/conformal/btcd/limits"
"github.com/conformal/btcdb"
_ "github.com/conformal/btcdb/ldb"
"github.com/conformal/btclog"
@ -66,8 +67,14 @@ func main() {
return
}
// Use all processor cores.
runtime.GOMAXPROCS(runtime.NumCPU())
// Up some limits.
if err := limits.SetLimits(); err != nil {
os.Exit(1)
}
backendLogger := btclog.NewDefaultBackendLogger()
defer backendLogger.Flush()
log = btclog.NewSubsystemLogger(backendLogger, "")