diff --git a/frontend/main.go b/frontend/main.go index 951fef8b..d88e779f 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -17,12 +17,14 @@ func main() { var bind = flag.String("bind", "127.0.0.1:8080", "Bind port/socket") var prefix = flag.String("prefix", "/", "Request path prefix to strip (from proxy)") var teamsDir = flag.String("teams", "./TEAMS/", "Base directory where find existing teams") - flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where load and save settings") + flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where read settings") + flag.StringVar(&startedFile, "startedFile", startedFile, "Path to the file to create/remove whether or not the challenge is running") flag.StringVar(&SubmissionDir, "submission", "./submissions/", "Base directory where save submissions") flag.Parse() log.SetPrefix("[frontend] ") + startedFile = path.Clean(startedFile) SubmissionDir = path.Clean(SubmissionDir) TmpSubmissionDir = path.Join(SubmissionDir, ".tmp") diff --git a/frontend/settings.go b/frontend/settings.go index a4e6bb99..335b4c97 100644 --- a/frontend/settings.go +++ b/frontend/settings.go @@ -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)