mirror of
https://github.com/dokku/dokku.git
synced 2026-08-29 01:59:07 +02:00
Cron containers were never reaped once they exceeded their active deadline, so a hung cron task ran indefinitely instead of being retired after 24 hours as documented. `cron:run` now also accepts a `--ttl-seconds` argument, matching the one `dokku run` already takes.
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
const (
|
|
helpHeader = `Usage: dokku cron[:COMMAND]
|
|
|
|
Manage scheduled cron tasks
|
|
|
|
Additional commands:`
|
|
|
|
helpContent = `
|
|
cron:list <app> [--format json|stdout], List scheduled cron tasks for an app
|
|
cron:report [<app>] [<flag>], Display report about an app
|
|
cron:resume <app> <cron_id>, Resume a cron task
|
|
cron:run <app> <cron_id> [--detach] [--ttl-seconds SECONDS], Run a cron task on the fly
|
|
cron:set [--global|<app>] <key> <value>, Set or clear a cron property for an app
|
|
cron:suspend <app> <cron_id>, Suspend a cron task`
|
|
)
|
|
|
|
func main() {
|
|
flag.Usage = usage
|
|
flag.Parse()
|
|
|
|
cmd := flag.Arg(0)
|
|
switch cmd {
|
|
case "cron", "cron:help":
|
|
usage()
|
|
case "help":
|
|
result, err := common.CallExecCommand(common.ExecCommandInput{
|
|
Command: "ps",
|
|
Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())},
|
|
})
|
|
if err == nil && strings.Contains(result.StdoutContents(), "--all") {
|
|
fmt.Println(helpContent)
|
|
} else {
|
|
fmt.Print("\n cron, Manage scheduled cron tasks\n")
|
|
}
|
|
default:
|
|
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
|
|
if err != nil {
|
|
fmt.Println("failed to retrieve DOKKU_NOT_IMPLEMENTED_EXIT environment variable")
|
|
dokkuNotImplementExitCode = 10
|
|
}
|
|
os.Exit(dokkuNotImplementExitCode)
|
|
}
|
|
}
|
|
|
|
func usage() {
|
|
common.CommandUsage(helpHeader, helpContent)
|
|
}
|