log cron job errors
This commit is contained in:
parent
baacf4913b
commit
31670ab3e1
|
@ -5,6 +5,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -112,10 +113,14 @@ func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
|
||||||
pr := goja.MustCompile("", "{("+handler+").apply(undefined)}", true)
|
pr := goja.MustCompile("", "{("+handler+").apply(undefined)}", true)
|
||||||
|
|
||||||
err := scheduler.Add(jobId, cronExpr, func() {
|
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)
|
_, err := executor.RunProgram(pr)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil && app.IsDebug() {
|
||||||
|
fmt.Println("[cronAdd] failed to execute cron job " + jobId + ": " + err.Error())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("[cronAdd] failed to register cron job " + jobId + ": " + err.Error())
|
panic("[cronAdd] failed to register cron job " + jobId + ": " + err.Error())
|
||||||
|
|
Loading…
Reference in New Issue