frontend: move started file at a dedicated path

This commit is contained in:
nemunaire 2018-01-22 18:09:05 +01:00
commit 2e3b262a78
2 changed files with 7 additions and 6 deletions

View file

@ -3,19 +3,18 @@ package main
import (
"log"
"os"
"path"
"time"
fronttime "srs.epita.fr/fic-server/frontend/time"
"srs.epita.fr/fic-server/settings"
)
const startedFile = "started"
var startedFile = "started"
var touchTimer *time.Timer = nil
func touchStartedFile() {
if fd, err := os.Create(path.Join(settings.SettingsDir, startedFile)); err == nil {
if fd, err := os.Create(startedFile); err == nil {
log.Println("Started! Go, Go, Go!!")
fd.Close()
} else {
@ -32,8 +31,8 @@ func reloadSettings(config settings.FICSettings) {
if startSub > 0 {
log.Println("Challenge will starts at", config.Start, "in", startSub)
if _, err := os.Stat(path.Join(settings.SettingsDir, startedFile)); !os.IsNotExist(err) {
os.Remove(path.Join(settings.SettingsDir, startedFile))
if _, err := os.Stat(startedFile); !os.IsNotExist(err) {
os.Remove(startedFile)
}
touchTimer = time.AfterFunc(config.Start.Sub(time.Now().Add(time.Duration(1 * time.Second))), touchStartedFile)