Browse Source

feat: support receive SIGALRM for update assets

v1.x.x
Dnomd343 2 years ago
parent
commit
c6ebbac544
  1. 12
      cmd/asset/update.go

12
cmd/asset/update.go

@ -4,7 +4,10 @@ import (
"XProxy/cmd/common" "XProxy/cmd/common"
"github.com/robfig/cron" "github.com/robfig/cron"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"os"
"os/signal"
"path" "path"
"syscall"
) )
type Config struct { type Config struct {
@ -42,4 +45,13 @@ func AutoUpdate(config *Config, assetDir string) { // set cron task for auto upd
}) })
autoUpdate.Start() 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)
} }

Loading…
Cancel
Save