diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/mirror/main.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmd/mirror/main.go b/cmd/mirror/main.go new file mode 100644 index 0000000..e8a7f6c --- /dev/null +++ b/cmd/mirror/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "flag" + "log" + "os" + + "git.server.ky/slackcoder/mirror/internal/service" +) + +type Flags struct { + Config string + Mirrors string +} + +func ParseFlags() *Flags { + var flags Flags + + flag.StringVar(&flags.Config, "config", "/etc/mirror/config.json", "configuration file") + + flag.Parse() + return &flags +} + +func exitOnError(err error) { + if err != nil { + log.Printf("%s", err) + os.Exit(-1) + } +} + +func main() { + flags := ParseFlags() + + var cfg service.Config + err := service.ApplyFileConfig(&cfg, flags.Config) + exitOnError(err) + + srv, err := service.NewService(&cfg) + exitOnError(err) + + err = srv.Run() + exitOnError(err) +} |