feat: add initial scheduled task implementation

This functionality enables users to manage a global crontab for the Dokku user that contains all scheduled tasks across all apps. Alternative schedulers can implement cron tasks as desired.
This commit is contained in:
Jose Diaz-Gonzalez
2021-01-18 18:15:42 -05:00
parent e00e498e50
commit f7ef14d737
23 changed files with 1026 additions and 391 deletions

View File

@@ -0,0 +1,35 @@
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
cron "github.com/dokku/dokku/plugins/cron"
)
// main entrypoint to all triggers
func main() {
parts := strings.Split(os.Args[0], "/")
trigger := parts[len(parts)-1]
flag.Parse()
var err error
switch trigger {
case "post-delete":
err = cron.TriggerPostDelete()
case "post-deploy":
err = cron.TriggerPostDeploy()
case "report":
appName := flag.Arg(0)
err = cron.ReportSingleApp(appName, "")
default:
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
}
if err != nil {
common.LogFail(err.Error())
}
}