Remove from frontend the settings distribution role
This commit is contained in:
parent
af6e86d4ef
commit
cfde1689cc
7 changed files with 28 additions and 37 deletions
|
|
@ -20,8 +20,7 @@ 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 read settings")
|
||||
flag.StringVar(&SettingsDistDir, "settingsDist", SettingsDistDir, "Directory where place settings to distribute")
|
||||
flag.StringVar(&settings.SettingsDir, "settings", "./SETTINGSDIST", "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")
|
||||
var simulator = flag.String("simulator", "", "Team to simulate (for development only)")
|
||||
|
|
@ -68,7 +67,7 @@ func main() {
|
|||
http.Handle(fmt.Sprintf("%s/teams.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||
http.Handle(fmt.Sprintf("%s/themes.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||
http.Handle(fmt.Sprintf("%s/stats.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||
http.Handle(fmt.Sprintf("%s/settings.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(SettingsDistDir))))
|
||||
http.Handle(fmt.Sprintf("%s/settings.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(settings.SettingsDir))))
|
||||
|
||||
// Serve static assets
|
||||
http.Handle(fmt.Sprintf("%s/css/", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(staticDir))))
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
|
|
@ -26,24 +24,6 @@ func touchStartedFile() {
|
|||
}
|
||||
|
||||
func reloadSettings(config *settings.Settings) {
|
||||
// Copy the new settings file for distribution
|
||||
if data, err := ioutil.ReadFile(path.Join(settings.SettingsDir, settings.SettingsFile)); err != nil {
|
||||
log.Println("Unable to read settings file:", err)
|
||||
} else if err = ioutil.WriteFile(path.Join(SettingsDistDir, settings.SettingsFile+".tmp"), data, 0644); err != nil {
|
||||
log.Println("Unable to write tmp settings file:", err)
|
||||
} else if err := os.Rename(path.Join(SettingsDistDir, settings.SettingsFile+".tmp"), path.Join(SettingsDistDir, settings.SettingsFile)); err != nil {
|
||||
log.Println("Unable to move new settings file:", err)
|
||||
}
|
||||
|
||||
// Copy the challenge info file for distribution
|
||||
if data, err := ioutil.ReadFile(path.Join(settings.SettingsDir, settings.ChallengeFile)); err != nil {
|
||||
log.Println("Unable to read challenge info file:", err)
|
||||
} else if err = ioutil.WriteFile(path.Join(SettingsDistDir, settings.ChallengeFile+".tmp"), data, 0644); err != nil {
|
||||
log.Println("Unable to write tmp challenge info file:", err)
|
||||
} else if err := os.Rename(path.Join(SettingsDistDir, settings.ChallengeFile+".tmp"), path.Join(SettingsDistDir, settings.ChallengeFile)); err != nil {
|
||||
log.Println("Unable to move new challenge info file:", err)
|
||||
}
|
||||
|
||||
if challengeStart != config.Start || challengeEnd != config.End {
|
||||
if touchTimer != nil {
|
||||
touchTimer.Stop()
|
||||
|
|
|
|||
Reference in a new issue