✨ Hot reload
This commit is contained in:
parent
7b544f370d
commit
d2710d1718
@ -49,6 +49,7 @@ func ReadInConfig(root string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Hot swap
|
||||
R = instance
|
||||
|
||||
return nil
|
||||
|
@ -3,14 +3,19 @@ package navi
|
||||
import "code.smartsheep.studio/goatworks/roadsign/pkg/warden"
|
||||
|
||||
func InitializeWarden(regions []*Region) {
|
||||
pool := make([]*warden.AppInstance, 0)
|
||||
|
||||
for _, region := range regions {
|
||||
for _, application := range region.Applications {
|
||||
warden.InstancePool = append(warden.InstancePool, &warden.AppInstance{
|
||||
pool = append(pool, &warden.AppInstance{
|
||||
Manifest: application,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Hot swap
|
||||
warden.InstancePool = pool
|
||||
|
||||
for _, instance := range warden.InstancePool {
|
||||
instance.Wake()
|
||||
}
|
||||
|
18
pkg/sideload/reload.go
Normal file
18
pkg/sideload/reload.go
Normal file
@ -0,0 +1,18 @@
|
||||
package sideload
|
||||
|
||||
import (
|
||||
"code.smartsheep.studio/goatworks/roadsign/pkg/navi"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func doReload(c *fiber.Ctx) error {
|
||||
if err := navi.ReadInConfig(viper.GetString("paths.configs")); err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
if c.QueryBool("warden", false) {
|
||||
navi.InitializeWarden(navi.R.Regions)
|
||||
}
|
||||
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
@ -52,6 +52,8 @@ func InitSideload() *fiber.App {
|
||||
cgi.Get("/regions/cfg/:id", getRegionConfig)
|
||||
cgi.Get("/applications", getApplications)
|
||||
cgi.Get("/applications/logs/:id", getApplicationLogs)
|
||||
|
||||
cgi.Post("/reload", doReload)
|
||||
}
|
||||
|
||||
webhooks := app.Group("/webhooks").Name("WebHooks")
|
||||
|
Loading…
Reference in New Issue
Block a user