evdist: Add interrupts to consult state
This commit is contained in:
parent
0ca7aa568d
commit
f32873f307
@ -5,8 +5,10 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
@ -85,6 +87,12 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Register SIGUSR1 and SIGTERM
|
||||
interrupt1 := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt1, syscall.SIGUSR1)
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, syscall.SIGTERM)
|
||||
|
||||
watchedNotify := fsnotify.Create
|
||||
|
||||
treatNewFile := func(name string) {
|
||||
@ -95,8 +103,17 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
case <-interrupt:
|
||||
break loop
|
||||
case <-interrupt1:
|
||||
log.Println("SIGUSR1 received, displaying queues")
|
||||
log.Println("Seeing settings distlist")
|
||||
lSettings.Print()
|
||||
log.Println("Seeing dashboard distlist")
|
||||
lDashboard.Print()
|
||||
case <-lSettings.Timer.C:
|
||||
if v := lSettings.Pop(); v != nil {
|
||||
log.Printf("TREATING SETTINGS DIFF: %v", v)
|
||||
|
Loading…
x
Reference in New Issue
Block a user