Change project layout to make easier debug / tests"

This commit is contained in:
eleksir
2024-09-22 23:52:57 +03:00
parent 9d3bc186cc
commit 4bff21f4c7
112 changed files with 271 additions and 1683 deletions

35
internal/lib/signal.go Normal file
View File

@@ -0,0 +1,35 @@
package lib
import (
"log"
"os"
"syscall"
)
var PrintOutput = true
// SigHandler OS signal handler.
func (c MyConfig) SigHandler() {
for s := range c.SigChan {
switch s {
case syscall.SIGUSR1:
log.Print("Got SIGUSR1, stopping output")
PrintOutput = false
case syscall.SIGUSR2:
log.Print("Got SIGUSR2, resuming output")
PrintOutput = true
c.UpdateReady <- true
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
os.Exit(0)
// We have signal that we're not interested in, so make a new loop iteration.
default:
continue
}
}
}