From 0a0027fb28f0150f1a3749937c5e6024f6808426 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Thu, 30 Jan 2025 20:25:43 -0500 Subject: [PATCH] Improves daemon --- app/action_daemon.go | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/app/action_daemon.go b/app/action_daemon.go index c685b02..8c95f7e 100644 --- a/app/action_daemon.go +++ b/app/action_daemon.go @@ -75,25 +75,33 @@ func (k *KhedraApp) daemonAction(c *cli.Context) error { controlService := services.NewControlService(k.logger.GetLogger()) activeServices = append(activeServices, controlService) for _, svc := range k.config.Services { - if svc.Enabled { - switch svc.Name { - case "scraper": - chains := strings.Split(strings.ReplaceAll(k.config.EnabledChains(), " ", ""), ",") - scraperSvc := services.NewScrapeService( - k.logger.GetLogger(), - "all", - chains, - k.config.Services["scraper"].Sleep, - k.config.Services["scraper"].BatchSize, - ) - activeServices = append(activeServices, scraperSvc) - case "monitor": - monitorSvc := services.NewMonitorService(nil) - activeServices = append(activeServices, monitorSvc) - case "api": + switch svc.Name { + case "scraper": + chains := strings.Split(strings.ReplaceAll(k.config.EnabledChains(), " ", ""), ",") + scraperSvc := services.NewScrapeService( + k.logger.GetLogger(), + "all", + chains, + k.config.Services["scraper"].Sleep, + k.config.Services["scraper"].BatchSize, + ) + activeServices = append(activeServices, scraperSvc) + if !svc.Enabled { + scraperSvc.Pause() + } + case "monitor": + monitorSvc := services.NewMonitorService(nil) + activeServices = append(activeServices, monitorSvc) + if !svc.Enabled { + monitorSvc.Pause() + } + case "api": + if svc.Enabled { apiSvc := services.NewApiService(k.logger.GetLogger()) activeServices = append(activeServices, apiSvc) - case "ipfs": + } + case "ipfs": + if svc.Enabled { ipfsSvc := services.NewIpfsService(k.logger.GetLogger()) activeServices = append(activeServices, ipfsSvc) }