feature: #202 Cron seconds support optional. Example in default config. (#223)

This commit is contained in:
James Read 2024-02-02 22:58:30 +01:00 committed by GitHub
parent 16acf9db91
commit 0615a7e353
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,9 @@ actions:
shellAfterCompleted: "apprise -t 'Notification: Backup script completed' -b 'The backup script completed with code {{ exitCode}}. The log is: \n {{ stdout }} '"
maxConcurrent: 1
icon: backup
execOnCron: # https://docs.olivetin.app/exec-cron.html
- "@monthly" # Once per month
- "0 12 25 12 *" # And on Christmas day!
# This will send 1 ping (-c 1)
# Docs: https://docs.olivetin.app/action-ping.html

View File

@ -88,6 +88,7 @@ type Config struct {
DefaultPermissions PermissionsList
AccessControlLists []AccessControlList
WebUIDir string
CronSupportForSeconds bool
}
// DefaultConfig gets a new Config structure with sensible default values.
@ -110,6 +111,7 @@ func DefaultConfig() *Config {
config.AuthJwtClaimUsername = "name"
config.AuthJwtClaimUserGroup = "group"
config.WebUIDir = "./webui"
config.CronSupportForSeconds = false
return &config
}

View File

@ -9,7 +9,13 @@ import (
)
func Schedule(cfg *config.Config, ex *executor.Executor) {
scheduler := cron.New(cron.WithSeconds())
var scheduler *cron.Cron
if cfg.CronSupportForSeconds {
scheduler = cron.New(cron.WithSeconds())
} else {
scheduler = cron.New()
}
for _, action := range cfg.Actions {
for _, cronline := range action.ExecOnCron {