From c6ebbac544de40a7d306d08c4805ef3e40c58669 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 1 Apr 2023 19:55:51 +0800 Subject: [PATCH] feat: support receive SIGALRM for update assets --- cmd/asset/update.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/asset/update.go b/cmd/asset/update.go index 3f0d492..bb14d8c 100644 --- a/cmd/asset/update.go +++ b/cmd/asset/update.go @@ -4,7 +4,10 @@ import ( "XProxy/cmd/common" "github.com/robfig/cron" log "github.com/sirupsen/logrus" + "os" + "os/signal" "path" + "syscall" ) type Config struct { @@ -42,4 +45,13 @@ func AutoUpdate(config *Config, assetDir string) { // set cron task for auto upd }) autoUpdate.Start() } + updateChan := make(chan os.Signal, 1) + go func() { + for { + <-updateChan + log.Infof("Receive SIGALRM -> update assets") + updateAsset(config.Update.Url, assetDir, config.Update.Proxy) + } + }() + signal.Notify(updateChan, syscall.SIGALRM) }