🐛 Fix preheat didn't run yet
All checks were successful
release-nightly / build-docker (push) Successful in 1m7s

This commit is contained in:
LittleSheep 2023-12-13 13:16:00 +08:00
parent 426af568dc
commit eae2b12764
3 changed files with 14 additions and 2 deletions

View File

@ -40,6 +40,7 @@ func doSyncSite(c *fiber.Ctx) error {
// Reload
sign.ReadInConfig(viper.GetString("paths.configs"))
sign.App.PreheatProcesses(func(total int, success int) {})
return c.SendStatus(fiber.StatusOK)
}

View File

@ -50,6 +50,12 @@ func main() {
log.Info().Int("count", len(sign.App.Sites)).Msg("All configuration has been loaded.")
}
// Preheat processes
log.Info().Msg("Preheating processes...")
sign.App.PreheatProcesses(func(total int, success int) {
log.Info().Int("requested", total).Int("succeed", success).Msgf("Preheat processes completed!")
})
// Init hypertext server
hypertext.RunServer(
hypertext.InitServer(),

View File

@ -80,7 +80,7 @@ func (v *ProcessConfig) StopProcess() error {
return nil
}
func (v *RoadApp) PreheatProcesses() {
func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) {
var processes []*ProcessConfig
for _, site := range v.Sites {
for _, process := range site.Processes {
@ -90,7 +90,12 @@ func (v *RoadApp) PreheatProcesses() {
}
}
success := 0
for _, process := range processes {
process.BootProcess()
if process.BootProcess() == nil {
success++
}
}
callback(len(processes), success)
}