config: use CLI worker configuration instead of NumCPU()

This commit is contained in:
Conner Fromknecht 2019-03-13 20:32:39 -07:00
parent 3f181b3c06
commit 76116f0d1a
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 10 additions and 4 deletions

@ -252,6 +252,8 @@ type config struct {
net tor.Net net tor.Net
Routing *routing.Conf `group:"routing" namespace:"routing"` Routing *routing.Conf `group:"routing" namespace:"routing"`
Workers *lncfg.Workers `group:"workers" namespace:"workers"`
} }
// loadConfig initializes and parses the config using a config file and command // loadConfig initializes and parses the config using a config file and command
@ -334,6 +336,11 @@ func loadConfig() (*config, error) {
Control: defaultTorControl, Control: defaultTorControl,
}, },
net: &tor.ClearNet{}, net: &tor.ClearNet{},
Workers: &lncfg.Workers{
Read: lncfg.DefaultReadWorkers,
Write: lncfg.DefaultWriteWorkers,
Sig: lncfg.DefaultSigWorkers,
},
} }
// Pre-parse the command line options to pick up an alternative config // Pre-parse the command line options to pick up an alternative config

@ -11,7 +11,6 @@ import (
"net" "net"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime"
"strconv" "strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -272,7 +271,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
) )
writePool := pool.NewWrite( writePool := pool.NewWrite(
writeBufferPool, runtime.NumCPU(), pool.DefaultWorkerTimeout, writeBufferPool, cfg.Workers.Write, pool.DefaultWorkerTimeout,
) )
readBufferPool := pool.NewReadBuffer( readBufferPool := pool.NewReadBuffer(
@ -281,13 +280,13 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
) )
readPool := pool.NewRead( readPool := pool.NewRead(
readBufferPool, runtime.NumCPU(), pool.DefaultWorkerTimeout, readBufferPool, cfg.Workers.Read, pool.DefaultWorkerTimeout,
) )
s := &server{ s := &server{
chanDB: chanDB, chanDB: chanDB,
cc: cc, cc: cc,
sigPool: lnwallet.NewSigPool(runtime.NumCPU()*2, cc.signer), sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.signer),
writePool: writePool, writePool: writePool,
readPool: readPool, readPool: readPool,