adjust the configuration check sequence (#1467)
Signed-off-by: zc <zc2638@qq.com>
This commit is contained in:
parent
96e62223b4
commit
1936acfd07
|
|
@ -112,6 +112,15 @@ func initDfcacheDfpath(cfg *config.CacheOption) (dfpath.Dfpath, error) {
|
||||||
|
|
||||||
// runDfcache does some init operations and starts to download.
|
// runDfcache does some init operations and starts to download.
|
||||||
func runDfcacheSubcmd(cmdName string, args []string) error {
|
func runDfcacheSubcmd(cmdName string, args []string) error {
|
||||||
|
// Convert config
|
||||||
|
if err := dfcacheConfig.Convert(cmdName, args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Validate config
|
||||||
|
if err := dfcacheConfig.Validate(cmdName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
daemonClient client.DaemonClient
|
daemonClient client.DaemonClient
|
||||||
err error
|
err error
|
||||||
|
|
@ -129,16 +138,6 @@ func runDfcacheSubcmd(cmdName string, args []string) error {
|
||||||
}
|
}
|
||||||
logger.Infof("Version:\n%s", version.Version())
|
logger.Infof("Version:\n%s", version.Version())
|
||||||
|
|
||||||
// Convert config
|
|
||||||
if err := dfcacheConfig.Convert(cmdName, args); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate config
|
|
||||||
if err := dfcacheConfig.Validate(cmdName); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dfcache config values
|
// Dfcache config values
|
||||||
s, _ := yaml.Marshal(dfcacheConfig)
|
s, _ := yaml.Marshal(dfcacheConfig)
|
||||||
logger.Infof("client dfcache configuration:\n%s", string(s))
|
logger.Infof("client dfcache configuration:\n%s", string(s))
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,15 @@ it supports container engine, wget and other downloading tools through proxy fun
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
|
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Convert config
|
||||||
|
if err := cfg.Convert(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Validate config
|
||||||
|
if err := cfg.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize daemon dfpath
|
// Initialize daemon dfpath
|
||||||
d, err := initDaemonDfpath(cfg)
|
d, err := initDaemonDfpath(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -67,16 +76,6 @@ it supports container engine, wget and other downloading tools through proxy fun
|
||||||
}
|
}
|
||||||
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "daemon"))
|
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "daemon"))
|
||||||
|
|
||||||
// Convert config
|
|
||||||
if err := cfg.Convert(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate config
|
|
||||||
if err := cfg.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return runDaemon(d)
|
return runDaemon(d)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,15 @@ var rootCmd = &cobra.Command{
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
// Convert config
|
||||||
|
if err := dfgetConfig.Convert(args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Validate config
|
||||||
|
if err := dfgetConfig.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize daemon dfpath
|
// Initialize daemon dfpath
|
||||||
d, err := initDfgetDfpath(dfgetConfig)
|
d, err := initDfgetDfpath(dfgetConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -83,16 +92,6 @@ var rootCmd = &cobra.Command{
|
||||||
// update plugin directory
|
// update plugin directory
|
||||||
source.UpdatePluginDir(d.PluginDir())
|
source.UpdatePluginDir(d.PluginDir())
|
||||||
|
|
||||||
// Convert config
|
|
||||||
if err := dfgetConfig.Convert(args); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate config
|
|
||||||
if err := dfgetConfig.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("--%s-- %s\n", start.Format("2006-01-02 15:04:05"), dfgetConfig.URL)
|
fmt.Printf("--%s-- %s\n", start.Format("2006-01-02 15:04:05"), dfgetConfig.URL)
|
||||||
fmt.Printf("dfget version: %s\n", version.GitVersion)
|
fmt.Printf("dfget version: %s\n", version.GitVersion)
|
||||||
fmt.Printf("current user: %s, default peer ip: %s\n", basic.Username, ip.IPv4)
|
fmt.Printf("current user: %s, default peer ip: %s\n", basic.Username, ip.IPv4)
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,11 @@ for managing schedulers and seed peers, offering http apis and portal, etc.`,
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Validate config
|
||||||
|
if err := cfg.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize dfpath
|
// Initialize dfpath
|
||||||
d, err := initDfpath(cfg.Server)
|
d, err := initDfpath(cfg.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -58,11 +63,6 @@ for managing schedulers and seed peers, offering http apis and portal, etc.`,
|
||||||
}
|
}
|
||||||
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "manager"))
|
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "manager"))
|
||||||
|
|
||||||
// Validate config
|
|
||||||
if err := cfg.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return runManager(d)
|
return runManager(d)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ generate and maintain a P2P network during the download process, and push suitab
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
// Validate config
|
||||||
|
if err := cfg.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
@ -62,11 +67,6 @@ generate and maintain a P2P network during the download process, and push suitab
|
||||||
}
|
}
|
||||||
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "scheduler"))
|
logger.RedirectStdoutAndStderr(cfg.Console, path.Join(d.LogDir(), "scheduler"))
|
||||||
|
|
||||||
// Validate config
|
|
||||||
if err := cfg.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return runScheduler(ctx, d)
|
return runScheduler(ctx, d)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue