Skip to content

Commit

Permalink
log cron job errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Sep 1, 2023
1 parent baacf49 commit 31670ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/jsvm/binds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -112,10 +113,14 @@ func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
pr := goja.MustCompile("", "{("+handler+").apply(undefined)}", true)

err := scheduler.Add(jobId, cronExpr, func() {
executors.run(func(executor *goja.Runtime) error {
err := executors.run(func(executor *goja.Runtime) error {
_, err := executor.RunProgram(pr)
return err
})

if err != nil && app.IsDebug() {
fmt.Println("[cronAdd] failed to execute cron job " + jobId + ": " + err.Error())
}
})
if err != nil {
panic("[cronAdd] failed to register cron job " + jobId + ": " + err.Error())
Expand Down

0 comments on commit 31670ab

Please sign in to comment.