evdist: Publish next settings change
This commit is contained in:
parent
357944564b
commit
0db9e9b539
5 changed files with 76 additions and 21 deletions
|
|
@ -29,8 +29,8 @@ type Settings struct {
|
|||
Start time.Time `json:"start"`
|
||||
// End is the expected end time (if empty their is no end-date).
|
||||
End *time.Time `json:"end,omitempty"`
|
||||
// ActivateTime is the time when the current file should be proceed.
|
||||
ActivateTime time.Time `json:"activateTime"`
|
||||
// NextChangeTime is the time of the next expected reload.
|
||||
NextChangeTime *time.Time `json:"nextchangetime,omitempty"`
|
||||
|
||||
// FirstBlood is the coefficient applied to each first team who solve a challenge.
|
||||
FirstBlood float64 `json:"firstBlood"`
|
||||
|
|
@ -193,11 +193,6 @@ func LoadAndWatchSettings(settingsPath string, reload func(*Settings)) {
|
|||
func tryReload(settingsPath string, reload func(*Settings)) {
|
||||
if config, err := ReadSettings(settingsPath); err != nil {
|
||||
log.Println("ERROR: Unable to read challenge settings:", err)
|
||||
} else if time.Until(config.ActivateTime) > 0 {
|
||||
log.Println("Configuration reloading postponed, activating at:", config.ActivateTime)
|
||||
time.Sleep(time.Until(config.ActivateTime))
|
||||
log.Println("Time to activate configuration...")
|
||||
tryReload(settingsPath, reload)
|
||||
} else {
|
||||
reload(config)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue