frontend: copy settings.json on settings reload (to handle delayed settings propagation)
This commit is contained in:
parent
4820d42327
commit
caea02bb4d
6 changed files with 29 additions and 4 deletions
|
@ -21,6 +21,7 @@ func main() {
|
|||
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(&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)")
|
||||
|
@ -40,6 +41,13 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
log.Println("Creating settingsDist directory...")
|
||||
if _, err := os.Stat(SettingsDistDir); os.IsNotExist(err) {
|
||||
if err = os.MkdirAll(SettingsDistDir, 0755); err != nil {
|
||||
log.Fatal("Unable to create settingsdist directory:", err)
|
||||
}
|
||||
}
|
||||
|
||||
*prefix = strings.TrimRight(*prefix, "/")
|
||||
|
||||
// Load configuration
|
||||
|
@ -67,7 +75,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(settings.SettingsDir))))
|
||||
http.Handle(fmt.Sprintf("%s/settings.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(SettingsDistDir))))
|
||||
|
||||
// Serve static assets
|
||||
http.Handle(fmt.Sprintf("%s/css/", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(staticDir))))
|
||||
|
|
Reference in a new issue