aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
-rw-r--r--cmd/mirror/main.go17
-rw-r--r--internal/service/service.go5
2 files changed, 22 insertions, 0 deletions
diff --git a/cmd/mirror/main.go b/cmd/mirror/main.go
index e8a00ac..1da9b15 100644
--- a/cmd/mirror/main.go
+++ b/cmd/mirror/main.go
@@ -5,6 +5,8 @@ import (
"fmt"
"log"
"os"
+ "os/signal"
+ "syscall"
"git.server.ky/slackcoder/mirror/internal/service"
)
@@ -36,6 +38,15 @@ func exitOnError(err error) {
}
}
+func handleSignal(c <-chan os.Signal, srv *service.Service) {
+ for v := range c {
+ if v == syscall.SIGHUP {
+ var cfg service.Config
+ _ = srv.Reload(&cfg)
+ }
+ }
+}
+
func main() {
flags := ParseFlags()
@@ -45,6 +56,9 @@ func main() {
os.Exit(0)
}
+ signalCh := make(chan os.Signal, 1)
+ signal.Notify(signalCh, syscall.SIGHUP)
+
var cfg service.Config
c, err := service.ReadConfigDir(flags.ConfigDir)
@@ -60,6 +74,9 @@ func main() {
srv, err := service.NewService(&cfg)
exitOnError(err)
+ signalCh = make(chan os.Signal, 1)
+ signal.Notify(signalCh, syscall.SIGHUP)
+
err = srv.Run()
exitOnError(err)
}
diff --git a/internal/service/service.go b/internal/service/service.go
index 21df14b..3038a03 100644
--- a/internal/service/service.go
+++ b/internal/service/service.go
@@ -146,6 +146,11 @@ func (s *Service) RemoveMirror(arg *Mirror) error {
return errors.New("not found")
}
+// Take arguments
+func (s *Service) Reload(cfg *Config) error {
+ return errors.New("not implemented")
+}
+
func (s *Service) Log(str string) {
escaped := []rune(strconv.Quote(strings.TrimSpace(str)))
escaped = escaped[1 : len(escaped)-1]