feat(11-02): add schedule:run as a scheduler process and a cron --once mode
- schedule:run runs a worker on the scheduled queue with every plugin's periodic jobs - schedule:run --once runs entries due in the current app.timezone minute without River, warns and skips unregistered commands, and returns the first command error - summer schedule:run delegate forwards --once - tests for --once minute matching, forged-entry skipping (T-11-09) and ByPeriod dedupe
This commit is contained in:
@@ -6,10 +6,11 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/bonfire"
|
||||
"git.golem15.com/golem15/summercms/internal/build"
|
||||
"git.golem15.com/golem15/summercms/modules/bonfire"
|
||||
)
|
||||
|
||||
func delegateCommand(name, description string) bonfire.Command {
|
||||
@@ -63,6 +64,28 @@ func delegateQueueWorkCommand() bonfire.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func delegateScheduleRunCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "schedule:run",
|
||||
Description: "Run the scheduler in the app binary (or once for system cron)",
|
||||
Flags: []bonfire.Flag{{
|
||||
Name: "once",
|
||||
Description: "Run the entries due this minute and exit (for system cron)",
|
||||
Bare: true,
|
||||
}},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
argv := []string{"schedule:run"}
|
||||
if v, ok := in.Flag("once"); ok {
|
||||
if once, _ := strconv.ParseBool(v); once {
|
||||
argv = append(argv, "--once")
|
||||
}
|
||||
}
|
||||
argv = append(argv, in.Args()...)
|
||||
return runAppBinary(ctx, argv, out)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func runAppBinary(ctx context.Context, argv []string, out bonfire.Output) error {
|
||||
if len(argv) == 0 {
|
||||
return fmt.Errorf("summer: missing app command")
|
||||
|
||||
Reference in New Issue
Block a user