mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
Updated config to allow the ability to change the home directory (#109)
Can use -A or --appdata to change the directory for dcrd to store files.
This commit is contained in:
parent
936b379408
commit
851569f14e
14
config.go
14
config.go
@ -68,6 +68,7 @@ var runServiceCommand func(string) error
|
||||
//
|
||||
// See loadConfig for details on the configuration load process.
|
||||
type config struct {
|
||||
DcrdHomeDir string `short:"A" long:"appdata" description:"Path to dcrd home directory"`
|
||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
@ -313,6 +314,7 @@ func newConfigParser(cfg *config, so *serviceOptions, options flags.Options) *fl
|
||||
func loadConfig() (*config, []string, error) {
|
||||
// Default config.
|
||||
cfg := config{
|
||||
DcrdHomeDir: dcrdHomeDir,
|
||||
ConfigFile: defaultConfigFile,
|
||||
DebugLevel: defaultLogLevel,
|
||||
MaxPeers: defaultMaxPeers,
|
||||
@ -371,6 +373,18 @@ func loadConfig() (*config, []string, error) {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Update the home directory for dcrd if specified. Since the home
|
||||
// directory is updated, other variables need to be updated to
|
||||
// reflect the new changes.
|
||||
if len(preCfg.DcrdHomeDir) > 0 {
|
||||
cfg.DcrdHomeDir, _ = filepath.Abs(preCfg.DcrdHomeDir)
|
||||
cfg.ConfigFile = filepath.Join(cfg.DcrdHomeDir, defaultConfigFilename)
|
||||
cfg.DataDir = filepath.Join(cfg.DcrdHomeDir, defaultDataDirname)
|
||||
cfg.RPCKey = filepath.Join(cfg.DcrdHomeDir, "rpc.key")
|
||||
cfg.RPCCert = filepath.Join(cfg.DcrdHomeDir, "rpc.cert")
|
||||
cfg.LogDir = filepath.Join(cfg.DcrdHomeDir, defaultLogDirname)
|
||||
}
|
||||
|
||||
// Load additional config from file.
|
||||
var configFileError error
|
||||
parser := newConfigParser(&cfg, &serviceOpts, flags.Default)
|
||||
|
||||
2
dcrd.go
2
dcrd.go
@ -44,6 +44,8 @@ func dcrdMain(serverChan chan<- *server) error {
|
||||
|
||||
// Show version at startup.
|
||||
dcrdLog.Infof("Version %s", version())
|
||||
// Show dcrd home dir location
|
||||
dcrdLog.Debugf("Dcrd home dir: %s", cfg.DcrdHomeDir)
|
||||
|
||||
// Enable http profiling server if requested.
|
||||
if cfg.Profile != "" {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user