mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: set network in default config path
This commit is contained in:
parent
d229a1a607
commit
ed04120a1a
2 changed files with 26 additions and 12 deletions
|
|
@ -18,7 +18,9 @@ var (
|
|||
defaultLogDirname = "logs"
|
||||
defaultLogFilename = "loopd.log"
|
||||
defaultLogDir = filepath.Join(loopDirBase, defaultLogDirname)
|
||||
defaultConfigFile = filepath.Join(loopDirBase, defaultConfigFilename)
|
||||
defaultConfigFile = filepath.Join(
|
||||
loopDirBase, defaultNetwork, defaultConfigFilename,
|
||||
)
|
||||
|
||||
defaultMaxLogFiles = 3
|
||||
defaultMaxLogFileSize = 10
|
||||
|
|
|
|||
34
loopd/run.go
34
loopd/run.go
|
|
@ -137,17 +137,7 @@ func Run(rpcCfg RPCConfig) error {
|
|||
|
||||
// Parse ini file.
|
||||
loopDir := lncfg.CleanAndExpandPath(config.LoopDir)
|
||||
configFile := lncfg.CleanAndExpandPath(config.ConfigFile)
|
||||
|
||||
// If our loop directory is set and the config file parameter is not
|
||||
// set, we assume that they want to point to a config file in their
|
||||
// loop dir. However, if the config file has a non-default value, then
|
||||
// we leave the config parameter as its custom value.
|
||||
if loopDir != loopDirBase && configFile == defaultConfigFile {
|
||||
configFile = filepath.Join(
|
||||
loopDir, defaultConfigFilename,
|
||||
)
|
||||
}
|
||||
configFile := getConfigPath(config, loopDir)
|
||||
|
||||
if err := flags.IniParse(configFile, &config); err != nil {
|
||||
// If it's a parsing related error, then we'll return
|
||||
|
|
@ -237,3 +227,25 @@ func Run(rpcCfg RPCConfig) error {
|
|||
|
||||
return fmt.Errorf("unimplemented command %v", parser.Active.Name)
|
||||
}
|
||||
|
||||
// getConfigPath gets our config path based on the values that are set in our
|
||||
// config.
|
||||
func getConfigPath(cfg Config, loopDir string) string {
|
||||
// If the config file path provided by the user is set, then we just
|
||||
// use this value.
|
||||
if cfg.ConfigFile != defaultConfigFile {
|
||||
return lncfg.CleanAndExpandPath(cfg.ConfigFile)
|
||||
}
|
||||
|
||||
// If the user has set a loop directory that is different to the default
|
||||
// we will use this loop directory as the location of our config file.
|
||||
// We do not namespace by network, because this is a custom loop dir.
|
||||
if loopDir != loopDirBase {
|
||||
return filepath.Join(loopDir, defaultConfigFilename)
|
||||
}
|
||||
|
||||
// Otherwise, we are using our default loop directory, and the user did
|
||||
// not set a config file path. We use our default loop dir, namespaced
|
||||
// by network.
|
||||
return filepath.Join(loopDir, cfg.Network, defaultConfigFilename)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue