From 5516719ebb46d23e9015370f31f354e141e5ee51 Mon Sep 17 00:00:00 2001 From: Guney Saramali Date: Fri, 19 Jul 2024 14:52:31 +0300 Subject: [PATCH] refactor: Returning back to the log library instead of fmt refactor: Renaming the wallhaven_engine.go to wallhaven_service.go as it used to be fix: Removing SIGKILL since it cannot be traped and adding SIGHUB --- cmd/wallSync/main.go | 2 +- internal/services/{walhaven_engine.go => walhaven_service.go} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename internal/services/{walhaven_engine.go => walhaven_service.go} (98%) diff --git a/cmd/wallSync/main.go b/cmd/wallSync/main.go index 70d5117..c60abbd 100644 --- a/cmd/wallSync/main.go +++ b/cmd/wallSync/main.go @@ -54,7 +54,7 @@ func main() { externalService := initService(serviceArgs, args, imageUpdateChannel, imageCache) backgroundImagecService := services.NewBackgroundImageService(args, imageUpdateChannel, imageCache) - ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL) + ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) defer stop() go backgroundImagecService.Listen() diff --git a/internal/services/walhaven_engine.go b/internal/services/walhaven_service.go similarity index 98% rename from internal/services/walhaven_engine.go rename to internal/services/walhaven_service.go index 82894a9..2f95248 100644 --- a/internal/services/walhaven_engine.go +++ b/internal/services/walhaven_service.go @@ -120,7 +120,7 @@ func (w *WallHavenService) getMetaData() error { func (w WallHavenService) getRandomImage() (models.WallHavenData, error) { log.Println("Downloading image") var newArgs *models.WallhavenArgs = w.args - newArgs.Page = rand.IntN(w.metaData.LastPage-1) + 1 + newArgs.Page = rand.IntN(w.metaData.LastPage) response, err := w.requestEngine.DoRequest(http.MethodGet, utils.CreateUrlQuery(newArgs)) if err != nil { return models.WallHavenData{}, err