evdist: Add interrupts to consult state
This commit is contained in:
parent
0ca7aa568d
commit
f32873f307
@ -5,8 +5,10 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/settings"
|
"srs.epita.fr/fic-server/settings"
|
||||||
@ -85,6 +87,12 @@ func main() {
|
|||||||
log.Fatal(err)
|
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
|
watchedNotify := fsnotify.Create
|
||||||
|
|
||||||
treatNewFile := func(name string) {
|
treatNewFile := func(name string) {
|
||||||
@ -95,8 +103,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loop:
|
||||||
for {
|
for {
|
||||||
select {
|
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:
|
case <-lSettings.Timer.C:
|
||||||
if v := lSettings.Pop(); v != nil {
|
if v := lSettings.Pop(); v != nil {
|
||||||
log.Printf("TREATING SETTINGS DIFF: %v", v)
|
log.Printf("TREATING SETTINGS DIFF: %v", v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user