frontend: add a timestamp file for time checking on backend

This commit is contained in:
nemunaire 2019-10-31 15:35:10 +01:00
parent 6740256a32
commit fa33fac003

View File

@ -11,6 +11,7 @@ import (
"path" "path"
"strings" "strings"
"syscall" "syscall"
"time"
"srs.epita.fr/fic-server/settings" "srs.epita.fr/fic-server/settings"
) )
@ -95,8 +96,21 @@ func main() {
}() }()
log.Println(fmt.Sprintf("Ready, listening on %s", *bind)) log.Println(fmt.Sprintf("Ready, listening on %s", *bind))
// Wait shutdown signal // Wait shutdown signal and touch timestamp
<-interrupt ticker := time.NewTicker(time.Second)
defer ticker.Stop()
loop:
for {
select {
case <-interrupt:
break loop
case <-ticker.C:
now := time.Now()
os.Chtimes(SubmissionDir, now, now)
}
}
log.Print("The service is shutting down...") log.Print("The service is shutting down...")
srv.Shutdown(context.Background()) srv.Shutdown(context.Background())