trigger the jsvm cron ticker only on app serve
This commit is contained in:
parent
cc8c855306
commit
9254ce46eb
|
@ -1,8 +1,10 @@
|
|||
## v0.17.1
|
||||
|
||||
- Use relative path when redirecting to the OAuth2 providers page in the Admin UI to support subpath deployments ([#3026](https://github.com/pocketbase/pocketbase/pull/3026); thanks @sonyarianto).
|
||||
|
||||
- Manually trigger the `OnBeforeServe` hook for `tests.ApiScenario` ([#3025](https://github.com/pocketbase/pocketbase/discussions/3025)).
|
||||
|
||||
- Use relative path when redirecting to the OAuth2 providers page in the Admin UI to support subpath deployments ([#3026](https://github.com/pocketbase/pocketbase/pull/3026); thanks @sonyarianto).
|
||||
- Trigger the JSVM `cronAdd()` handler only on app `serve` to prevent unexpected (and eventually duplicated) cron handler calls when custom console commands are used ([#3024](https://github.com/pocketbase/pocketbase/discussions/3024#discussioncomment-6592703)).
|
||||
|
||||
|
||||
## v0.17.0
|
||||
|
|
|
@ -105,6 +105,8 @@ func hooksBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
|
|||
func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
|
||||
scheduler := cron.New()
|
||||
|
||||
var hasServeInited bool
|
||||
|
||||
loader.Set("cronAdd", func(jobId, cronExpr, handler string) {
|
||||
pr := goja.MustCompile("", "{("+handler+").apply(undefined)}", true)
|
||||
|
||||
|
@ -119,7 +121,7 @@ func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
|
|||
}
|
||||
|
||||
// start the ticker (if not already)
|
||||
if app.IsBootstrapped() && scheduler.Total() > 0 && !scheduler.HasStarted() {
|
||||
if hasServeInited && scheduler.Total() > 0 && !scheduler.HasStarted() {
|
||||
scheduler.Start()
|
||||
}
|
||||
})
|
||||
|
@ -133,12 +135,14 @@ func cronBinds(app core.App, loader *goja.Runtime, executors *vmsPool) {
|
|||
}
|
||||
})
|
||||
|
||||
app.OnAfterBootstrap().Add(func(e *core.BootstrapEvent) error {
|
||||
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
// start the ticker (if not already)
|
||||
if scheduler.Total() > 0 && !scheduler.HasStarted() {
|
||||
scheduler.Start()
|
||||
}
|
||||
|
||||
hasServeInited = true
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue