feat: block routine with for loop

This commit is contained in:
Urko 2023-02-26 16:19:12 +01:00
parent 19f17308b1
commit a67ef6f2d8
2 changed files with 9 additions and 15 deletions

24
main.go
View File

@ -35,21 +35,15 @@ func main() {
// Handle termination on ctrl+signalChan // Handle termination on ctrl+signalChan
signalChan := make(chan os.Signal, 1) signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM) signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)
for {
go func(errors chan error) { select {
for { case <-signalChan:
select { os.Exit(1)
case <-signalChan: case err := <-errors:
os.Exit(1) if err != nil {
case err := <-errors: log.Printf("watcherIface.Monitor: %s\n", err)
if err != nil { continue
log.Fatalf("watcherIface.Monitor: %s\n", err)
return
}
} }
} }
}(errors) }
// TODO: Improve this: Block main goroutine forever.
<-make(chan struct{})
} }