🎨 Improve callback functions
All checks were successful
release-nightly / build-docker (push) Successful in 1m6s
All checks were successful
release-nightly / build-docker (push) Successful in 1m6s
This commit is contained in:
parent
eae2b12764
commit
fb24f44e22
@ -29,7 +29,6 @@ func doSyncSite(c *fiber.Ctx) error {
|
|||||||
file.Write(raw)
|
file.Write(raw)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if site, ok := lo.Find(sign.App.Sites, func(item *sign.SiteConfig) bool {
|
if site, ok := lo.Find(sign.App.Sites, func(item *sign.SiteConfig) bool {
|
||||||
return item.ID == id
|
return item.ID == id
|
||||||
}); ok {
|
}); ok {
|
||||||
@ -40,7 +39,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) {})
|
sign.App.PreheatProcesses()
|
||||||
|
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.SendStatus(fiber.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (v *ProcessConfig) StopProcess() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) {
|
func (v *RoadApp) PreheatProcesses(callbacks ...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 {
|
||||||
@ -97,5 +97,9 @@ func (v *RoadApp) PreheatProcesses(callback func(total int, success int)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(len(processes), success)
|
if len(callbacks) > 0 {
|
||||||
|
for _, callback := range callbacks {
|
||||||
|
callback(len(processes), success)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user