🐛 Fix preheat didn't run yet
All checks were successful
release-nightly / build-docker (push) Successful in 1m7s
All checks were successful
release-nightly / build-docker (push) Successful in 1m7s
This commit is contained in:
parent
426af568dc
commit
eae2b12764
@ -40,6 +40,7 @@ func doSyncSite(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// Reload
|
// Reload
|
||||||
sign.ReadInConfig(viper.GetString("paths.configs"))
|
sign.ReadInConfig(viper.GetString("paths.configs"))
|
||||||
|
sign.App.PreheatProcesses(func(total int, success int) {})
|
||||||
|
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.SendStatus(fiber.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,12 @@ func main() {
|
|||||||
log.Info().Int("count", len(sign.App.Sites)).Msg("All configuration has been loaded.")
|
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
|
// Init hypertext server
|
||||||
hypertext.RunServer(
|
hypertext.RunServer(
|
||||||
hypertext.InitServer(),
|
hypertext.InitServer(),
|
||||||
|
@ -80,7 +80,7 @@ func (v *ProcessConfig) StopProcess() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *RoadApp) PreheatProcesses() {
|
func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) {
|
||||||
var processes []*ProcessConfig
|
var processes []*ProcessConfig
|
||||||
for _, site := range v.Sites {
|
for _, site := range v.Sites {
|
||||||
for _, process := range site.Processes {
|
for _, process := range site.Processes {
|
||||||
@ -90,7 +90,12 @@ func (v *RoadApp) PreheatProcesses() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
success := 0
|
||||||
for _, process := range processes {
|
for _, process := range processes {
|
||||||
process.BootProcess()
|
if process.BootProcess() == nil {
|
||||||
|
success++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callback(len(processes), success)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user