update api run app

This commit is contained in:
shoopea
2026-01-10 11:52:04 +01:00
parent b1a5084f94
commit 551651b9d2
2 changed files with 47 additions and 16 deletions

55
api.go
View File

@@ -124,23 +124,54 @@ func ApiRunApp(c *gin.Context) {
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting") log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("starting")
log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done") log.WithFields(log.Fields{"app": c.Param("app")}).Debugf("done")
if app, ok := cfg.apps[c.Param("app")]; ok { name := c.Param("app")
if err := app.RunStandaloneTime(time.Now()); err != nil { found := false
c.JSON(http.StatusInternalServerError, gin.H{ active := false
"message": "error", var (
"error": fmt.Sprint(err), app *App
}) err error
} else { )
c.JSON(http.StatusOK, gin.H{
"message": "done", for _, a := range cfg.Apps {
}) if a.Name == name {
found = true
active = a.Active
app, err = cfg.NewApp(a.Name, a.Sources, a.Destinations, a.Schedule, a.Before, a.After)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": fmt.Sprint(err),
})
return
}
} }
} else { }
if !found {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, gin.H{
"message": "error", "message": "error",
"app": c.Param("app"),
"error": "no app found", "error": "no app found",
}) })
return
}
if !active {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": "app not active",
})
return
}
if err := app.RunStandaloneTime(time.Now()); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "error",
"error": fmt.Sprint(err),
})
} else {
c.JSON(http.StatusOK, gin.H{
"message": "done",
})
} }
} }

View File

@@ -1,7 +1,7 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "ba418ed" var githash = "b1a5084"
var branch = "master" var branch = "master"
var buildstamp = "2026-01-10_10:43:42" var buildstamp = "2026-01-10_10:51:23"
var commits = "131" var commits = "132"
var version = "ba418ed-b131 - 2026-01-10_10:43:42" var version = "b1a5084-b132 - 2026-01-10_10:51:23"