mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
rpctest: Store logs and data in same path.
logs and data directories are subdirs of the harness dir, the node dcrd process is also run in the working dir which is the harness dir
This commit is contained in:
parent
fdb25c2f43
commit
18ca7bb19d
@ -70,16 +70,8 @@ func newConfig(prefix, certFile, keyFile string, extra []string) (*nodeConfig, e
|
||||
// temporary data, and log directories which must be cleaned up with a call to
|
||||
// cleanup().
|
||||
func (n *nodeConfig) setDefaults() error {
|
||||
datadir, err := ioutil.TempDir("", n.prefix+"-data")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.dataDir = datadir
|
||||
logdir, err := ioutil.TempDir("", n.prefix+"-logs")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.logDir = logdir
|
||||
n.dataDir = filepath.Join(n.prefix, "data")
|
||||
n.logDir = filepath.Join(n.prefix, "logs")
|
||||
cert, err := ioutil.ReadFile(n.certFile)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -165,21 +157,6 @@ func (n *nodeConfig) String() string {
|
||||
return n.prefix
|
||||
}
|
||||
|
||||
// cleanup removes the tmp data and log directories.
|
||||
func (n *nodeConfig) cleanup() error {
|
||||
dirs := []string{
|
||||
n.logDir,
|
||||
n.dataDir,
|
||||
}
|
||||
var err error
|
||||
for _, dir := range dirs {
|
||||
if err = os.RemoveAll(dir); err != nil {
|
||||
log.Printf("Cannot remove dir %s: %v", dir, err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// node houses the necessary state required to configure, launch, and manage a
|
||||
// dcrd process.
|
||||
type node struct {
|
||||
@ -212,8 +189,7 @@ func (n *node) start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
pid, err := os.Create(filepath.Join(n.dataDir,
|
||||
fmt.Sprintf("%s.pid", n.config)))
|
||||
pid, err := os.Create(filepath.Join(n.config.String(), "dcrd.pid"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -254,10 +230,11 @@ func (n *node) cleanup() error {
|
||||
if err := os.Remove(n.pidFile); err != nil {
|
||||
log.Printf("unable to remove file %s: %v", n.pidFile,
|
||||
err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return n.config.cleanup()
|
||||
return nil
|
||||
}
|
||||
|
||||
// shutdown terminates the running dcrd process, and cleans up all
|
||||
|
||||
@ -124,7 +124,7 @@ func New(activeNet *chaincfg.Params, handlers *dcrrpcclient.NotificationHandlers
|
||||
miningAddr := fmt.Sprintf("--miningaddr=%s", wallet.coinbaseAddr)
|
||||
extraArgs = append(extraArgs, miningAddr)
|
||||
|
||||
config, err := newConfig("rpctest", certFile, keyFile, extraArgs)
|
||||
config, err := newConfig(nodeTestData, certFile, keyFile, extraArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user