Deploy command

This commit is contained in:
2024-10-02 23:12:52 +08:00
parent ae12eb2a15
commit dd36e2ab1a
12 changed files with 154 additions and 35 deletions

View File

@ -46,7 +46,7 @@ func doPublish(c *fiber.Ctx) error {
}
} else if destination != nil && destination.GetType() != navi.DestinationStaticFile {
return fiber.ErrUnprocessableEntity
} else {
} else if destination == nil {
return fiber.ErrNotFound
}
@ -84,7 +84,7 @@ func doPublish(c *fiber.Ctx) error {
}
if instance != nil {
instance.Wake()
_ = instance.Wake()
}
return c.SendStatus(fiber.StatusOK)

View File

@ -43,24 +43,38 @@ func doSync(c *fiber.Ctx) error {
defer file.Close()
}
var rebootQueue []*warden.AppInstance
var stopQueue, startQueue []*warden.AppInstance
// Getting things need to stop
if region, ok := lo.Find(navi.R.Regions, func(item *navi.Region) bool {
return item.ID == id
}); ok {
for _, application := range region.Applications {
if instance := warden.GetFromPool(application.ID); instance != nil {
instance.Stop()
rebootQueue = append(rebootQueue, instance)
stopQueue = append(stopQueue, instance)
}
}
}
// Reload
navi.ReadInConfig(viper.GetString("paths.configs"))
_ = navi.ReadInConfig(viper.GetString("paths.configs"))
// Getting things need to start
if region, ok := lo.Find(navi.R.Regions, func(item *navi.Region) bool {
return item.ID == id
}); ok {
for _, application := range region.Applications {
if instance := warden.GetFromPool(application.ID); instance != nil {
startQueue = append(startQueue, instance)
}
}
}
// Reboot
for _, instance := range rebootQueue {
instance.Wake()
for _, instance := range stopQueue {
_ = instance.Stop()
}
for _, instance := range startQueue {
_ = instance.Start()
}
return c.SendStatus(fiber.StatusOK)