Skip to content

Commit

Permalink
refactor: add some log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nlif-m committed Jan 30, 2024
1 parent b048d06 commit 24de863
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ func main() {
TgBot(atomgen, atomFileUpdateChan)
}()

var wg sync.WaitGroup
var wg sync.WaitGroup // Why i use it since it non needed

go func(fullUpdateChan chan bool, atomFileUpdateChan chan bool) {
for {
select {
case <-fullUpdateChan:
wg.Add(1)
log.Println("Receive fullUpdateChan request")
err = atomgen.fullUpdate()
utils.CheckErr(err)
err = atomgen.generateAtomFeed()
Expand All @@ -79,16 +80,20 @@ func main() {

case <-atomFileUpdateChan:
wg.Add(1)
log.Println("Receive atomFileUpdateChan request")
err = atomgen.generateAtomFeed()
utils.CheckErr(err)
wg.Done()
}
}
}(fullUpdateChan, atomFileUpdateChan)

// Run timer to call update every cfg.ProgramRestartIntervalMinutes minutes
timeToSleep := time.Duration(cfg.ProgramRestartIntervalMinutes * uint(time.Minute))
tick := time.Tick(timeToSleep)
for {
<-tick
log.Println("Time to update, timer tick")
fullUpdateChan <- true
}
}

0 comments on commit 24de863

Please sign in to comment.