feat: add domain and external ip configuration items (#18)

This commit is contained in:
Li4n0
2021-05-22 20:40:04 +08:00
committed by GitHub
parent bc6e3962f8
commit 1144f67d37
55 changed files with 228 additions and 143 deletions
+12 -1
View File
@@ -47,10 +47,21 @@ func Start() {
configFile = c.Path("config")
}
conf := &server.Config{}
tpl := &server.Config{}
_ = yaml.Unmarshal(configTemplate, tpl)
if content, err := os.ReadFile(configFile); err == nil {
if err := yaml.Unmarshal(content, conf); err != nil {
return err
}
if conf.Version != tpl.Version {
backup := fmt.Sprintf("%s_%.1f", configFile, conf.Version)
log.Warn("Old version of configuration file detected, new configuration file being generated, old configuration backed up to %s", backup)
if err := os.WriteFile(backup, content, 0644); err != nil {
return err
}
return os.WriteFile(configFile, configTemplate, 0644)
}
} else if os.IsNotExist(err) && configFile == "config.yaml" {
log.Warn("Generate default configurations to config.yaml, please configure and run again.")
return os.WriteFile("config.yaml", configTemplate, 0644)
@@ -69,13 +80,13 @@ func Start() {
if c.String("log") != "" {
conf.Database = c.String("log")
}
fmt.Printf(banner, server.VERSION)
server.New(conf).Run()
return nil
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
fmt.Printf(banner, server.VERSION)
err := app.Run(os.Args)
if err != nil {