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("done")
if app, ok := cfg.apps[c.Param("app")]; ok {
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",
})
name := c.Param("app")
found := false
active := false
var (
app *App
err error
)
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{
"message": "error",
"app": c.Param("app"),
"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.
package main
var githash = "ba418ed"
var githash = "b1a5084"
var branch = "master"
var buildstamp = "2026-01-10_10:43:42"
var commits = "131"
var version = "ba418ed-b131 - 2026-01-10_10:43:42"
var buildstamp = "2026-01-10_10:51:23"
var commits = "132"
var version = "b1a5084-b132 - 2026-01-10_10:51:23"