config: Deprecate --configfile.
This removes the --configfile option from vspd. It introduced quite a few weird edge cases (and a fair bit of code to deal with them) but afaik nobody actually used it. Note that the --homedir option stays, so it is still possible to run vspd with config in a non-default location if required.
This commit is contained in:
parent
2bd340ba08
commit
8b6b2e4fef
@ -37,7 +37,6 @@ var (
|
|||||||
defaultHomeDir = dcrutil.AppDataDir(appName, false)
|
defaultHomeDir = dcrutil.AppDataDir(appName, false)
|
||||||
defaultConfigFilename = fmt.Sprintf("%s.conf", appName)
|
defaultConfigFilename = fmt.Sprintf("%s.conf", appName)
|
||||||
defaultDBFilename = fmt.Sprintf("%s.db", appName)
|
defaultDBFilename = fmt.Sprintf("%s.db", appName)
|
||||||
defaultConfigFile = filepath.Join(defaultHomeDir, defaultConfigFilename)
|
|
||||||
defaultDcrdHost = "127.0.0.1"
|
defaultDcrdHost = "127.0.0.1"
|
||||||
defaultWalletHost = "127.0.0.1"
|
defaultWalletHost = "127.0.0.1"
|
||||||
defaultWebServerDebug = false
|
defaultWebServerDebug = false
|
||||||
@ -74,7 +73,7 @@ type vspdConfig struct {
|
|||||||
ShowVersion bool `long:"version" no-ini:"true" description:"Display version information and exit."`
|
ShowVersion bool `long:"version" no-ini:"true" description:"Display version information and exit."`
|
||||||
FeeXPub string `long:"feexpub" no-ini:"true" description:"Cold wallet xpub used for collecting fees. Should be provided once to initialize a vspd database."`
|
FeeXPub string `long:"feexpub" no-ini:"true" description:"Cold wallet xpub used for collecting fees. Should be provided once to initialize a vspd database."`
|
||||||
HomeDir string `long:"homedir" no-ini:"true" description:"Path to application home directory. Used for storing VSP database and logs."`
|
HomeDir string `long:"homedir" no-ini:"true" description:"Path to application home directory. Used for storing VSP database and logs."`
|
||||||
ConfigFile string `long:"configfile" no-ini:"true" description:"Path to configuration file."`
|
ConfigFile string `long:"configfile" no-ini:"true" description:"DEPRECATED: This behavior is no longer available and this option will be removed in a future version of the software."`
|
||||||
|
|
||||||
logBackend *slog.Backend
|
logBackend *slog.Backend
|
||||||
logLevel slog.Level
|
logLevel slog.Level
|
||||||
@ -181,7 +180,6 @@ func loadConfig() (*vspdConfig, error) {
|
|||||||
NetworkName: defaultNetworkName,
|
NetworkName: defaultNetworkName,
|
||||||
VSPFee: defaultVSPFee,
|
VSPFee: defaultVSPFee,
|
||||||
HomeDir: defaultHomeDir,
|
HomeDir: defaultHomeDir,
|
||||||
ConfigFile: defaultConfigFile,
|
|
||||||
DcrdHost: defaultDcrdHost,
|
DcrdHost: defaultDcrdHost,
|
||||||
WalletHosts: defaultWalletHost,
|
WalletHosts: defaultWalletHost,
|
||||||
WebServerDebug: defaultWebServerDebug,
|
WebServerDebug: defaultWebServerDebug,
|
||||||
@ -195,8 +193,8 @@ func loadConfig() (*vspdConfig, error) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-parse the command line options to see if an alternative config file,
|
// Pre-parse the command line options to see if an alternative home dir or
|
||||||
// home dir, or the version flag were specified.
|
// the version flag were specified.
|
||||||
preCfg := cfg
|
preCfg := cfg
|
||||||
|
|
||||||
preParser := flags.NewParser(&preCfg, flags.None)
|
preParser := flags.NewParser(&preCfg, flags.None)
|
||||||
@ -217,20 +215,9 @@ func loadConfig() (*vspdConfig, error) {
|
|||||||
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
|
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
|
||||||
usageMessage := fmt.Sprintf("Use %s -h to show usage", appName)
|
usageMessage := fmt.Sprintf("Use %s -h to show usage", appName)
|
||||||
|
|
||||||
// Update the home directory if specified on CLI. Since the home
|
// Update the home directory if specified on CLI.
|
||||||
// directory is updated, other variables need to be updated to
|
|
||||||
// reflect the new changes.
|
|
||||||
if preCfg.HomeDir != "" {
|
if preCfg.HomeDir != "" {
|
||||||
cfg.HomeDir = cleanAndExpandPath(cfg.HomeDir)
|
cfg.HomeDir = cleanAndExpandPath(preCfg.HomeDir)
|
||||||
cfg.HomeDir, _ = filepath.Abs(preCfg.HomeDir)
|
|
||||||
|
|
||||||
if preCfg.ConfigFile == defaultConfigFile {
|
|
||||||
defaultConfigFile = filepath.Join(cfg.HomeDir, defaultConfigFilename)
|
|
||||||
preCfg.ConfigFile = defaultConfigFile
|
|
||||||
cfg.ConfigFile = defaultConfigFile
|
|
||||||
} else {
|
|
||||||
cfg.ConfigFile = preCfg.ConfigFile
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the home directory if it doesn't already exist.
|
// Create the home directory if it doesn't already exist.
|
||||||
@ -243,15 +230,16 @@ func loadConfig() (*vspdConfig, error) {
|
|||||||
|
|
||||||
// Create a default config file when one does not exist and the user did
|
// Create a default config file when one does not exist and the user did
|
||||||
// not specify an override.
|
// not specify an override.
|
||||||
if preCfg.ConfigFile == defaultConfigFile && !fileExists(preCfg.ConfigFile) {
|
configFile := filepath.Join(cfg.HomeDir, defaultConfigFilename)
|
||||||
|
if !fileExists(configFile) {
|
||||||
preIni := flags.NewIniParser(preParser)
|
preIni := flags.NewIniParser(preParser)
|
||||||
err = preIni.WriteFile(preCfg.ConfigFile,
|
err = preIni.WriteFile(configFile,
|
||||||
flags.IniIncludeComments|flags.IniIncludeDefaults)
|
flags.IniIncludeComments|flags.IniIncludeDefaults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error creating a default "+
|
return nil, fmt.Errorf("error creating a default "+
|
||||||
"config file: %w", err)
|
"config file: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Config file with default values written to %s\n", defaultConfigFile)
|
fmt.Printf("Config file with default values written to %s\n", configFile)
|
||||||
|
|
||||||
// File created, user now has to fill in values. Proceeding with the
|
// File created, user now has to fill in values. Proceeding with the
|
||||||
// default file just causes errors.
|
// default file just causes errors.
|
||||||
@ -261,7 +249,7 @@ func loadConfig() (*vspdConfig, error) {
|
|||||||
// Load additional config from file.
|
// Load additional config from file.
|
||||||
parser := flags.NewParser(&cfg, flags.None)
|
parser := flags.NewParser(&cfg, flags.None)
|
||||||
|
|
||||||
err = flags.NewIniParser(parser).ParseFile(preCfg.ConfigFile)
|
err = flags.NewIniParser(parser).ParseFile(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error parsing config file: %w", err)
|
return nil, fmt.Errorf("error parsing config file: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2020-2023 The Decred developers
|
// Copyright (c) 2020-2024 The Decred developers
|
||||||
// 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.
|
||||||
|
|
||||||
@ -55,13 +55,19 @@ func run() int {
|
|||||||
|
|
||||||
if cfg.network == &config.MainNet && version.IsPreRelease() {
|
if cfg.network == &config.MainNet && version.IsPreRelease() {
|
||||||
log.Warnf("")
|
log.Warnf("")
|
||||||
log.Warnf("\tWARNING: This is a pre-release version of vspd which should not be used on mainnet.")
|
log.Warnf("\tWARNING: This is a pre-release version of vspd which should not be used on mainnet")
|
||||||
log.Warnf("")
|
log.Warnf("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.VspClosed {
|
if cfg.VspClosed {
|
||||||
log.Warnf("")
|
log.Warnf("")
|
||||||
log.Warnf("\tWARNING: Config --vspclosed is set. This will prevent vspd from accepting new tickets.")
|
log.Warnf("\tWARNING: Config --vspclosed is set. This will prevent vspd from accepting new tickets")
|
||||||
|
log.Warnf("")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.ConfigFile != "" {
|
||||||
|
log.Warnf("")
|
||||||
|
log.Warnf("\tWARNING: Config --configfile is set. This is a deprecated option which has no effect and will be removed in a future release")
|
||||||
log.Warnf("")
|
log.Warnf("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,10 +170,10 @@ EOF
|
|||||||
tmux new-window -t $TMUX_SESSION -n "vspd"
|
tmux new-window -t $TMUX_SESSION -n "vspd"
|
||||||
|
|
||||||
echo "Creating vspd database"
|
echo "Creating vspd database"
|
||||||
tmux send-keys "vspd --configfile=${HARNESS_ROOT}/vspd/vspd.conf --homedir=${HARNESS_ROOT}/vspd --feexpub=${VSPD_FEE_XPUB}" C-m
|
tmux send-keys "vspd --homedir=${HARNESS_ROOT}/vspd --feexpub=${VSPD_FEE_XPUB}" C-m
|
||||||
sleep 3 # wait for database creation and ensure dcrwallet rpc listeners are started
|
sleep 3 # wait for database creation and ensure dcrwallet rpc listeners are started
|
||||||
echo "Starting vspd"
|
echo "Starting vspd"
|
||||||
tmux send-keys "vspd --configfile=${HARNESS_ROOT}/vspd/vspd.conf --homedir=${HARNESS_ROOT}/vspd" C-m
|
tmux send-keys "vspd --homedir=${HARNESS_ROOT}/vspd" C-m
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# All done - attach to tmux session.
|
# All done - attach to tmux session.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user