aboutsummaryrefslogtreecommitdiffsponsor
path: root/cmd
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-10-21 08:59:36 -0500
committerSlack Coder <slackcoder@server.ky>2024-10-21 08:59:36 -0500
commitdd3d5cfc0014e5f7ce529602cac09a1de41bdc3d (patch)
tree979d8c5f64fb5c537a79d8473d094a6796c7e889 /cmd
parent001262c0fff1944e1238362d510051bb50bb6b13 (diff)
downloadmirror-dd3d5cfc0014e5f7ce529602cac09a1de41bdc3d.tar.xz
Support multiple config files
Read files from /etc/mirror/conf.d.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mirror/main.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/mirror/main.go b/cmd/mirror/main.go
index e823039..e8a00ac 100644
--- a/cmd/mirror/main.go
+++ b/cmd/mirror/main.go
@@ -13,14 +13,16 @@ import (
var Version string
type Flags struct {
- Config string
- Version bool
+ Config string
+ ConfigDir string
+ Version bool
}
func ParseFlags() *Flags {
var flags Flags
- flag.StringVar(&flags.Config, "config", "/etc/mirror/mirror.toml", "configuration file")
+ flag.StringVar(&flags.Config, "config", "/etc/mirror/mirror.toml", "configuration file which takes precedence")
+ flag.StringVar(&flags.ConfigDir, "config-dir", "/etc/mirror/conf.d", "configuration directory")
flag.BoolVar(&flags.Version, "version", false, "print version")
flag.Parse()
@@ -39,13 +41,23 @@ func main() {
if flags.Version {
fmt.Println(Version)
+
os.Exit(0)
}
- cfg, err := service.ReadConfig(flags.Config)
+ var cfg service.Config
+
+ c, err := service.ReadConfigDir(flags.ConfigDir)
+ exitOnError(err)
+
+ cfg.Append(c)
+
+ c, err = service.ReadConfig(flags.Config)
exitOnError(err)
- srv, err := service.NewService(cfg)
+ cfg.Append(c)
+
+ srv, err := service.NewService(&cfg)
exitOnError(err)
err = srv.Run()