trigger OnTerminate() hook on app.Restart() call
This commit is contained in:
parent
afbbc1d97c
commit
4c473385b2
|
@ -75,6 +75,9 @@
|
||||||
- Use `IS NOT` instead of `!=` as not-equal SQL query operator to handle the cases when comparing with nullable columns or expressions (eg. `json_extract` over `json` field).
|
- Use `IS NOT` instead of `!=` as not-equal SQL query operator to handle the cases when comparing with nullable columns or expressions (eg. `json_extract` over `json` field).
|
||||||
_Based on my local dataset I wasn't able to find a significant difference in the performance between the 2 operators, but if you stumble on a query that you think may be affected negatively by this, please report it and I'll test it further._
|
_Based on my local dataset I wasn't able to find a significant difference in the performance between the 2 operators, but if you stumble on a query that you think may be affected negatively by this, please report it and I'll test it further._
|
||||||
|
|
||||||
|
- Trigger the `app.OnTerminate()` hook on `app.Restart()` call.
|
||||||
|
_A new bool `IsRestart` field was also added to the `core.TerminateEvent` event._
|
||||||
|
|
||||||
|
|
||||||
## v0.20.0-rc3
|
## v0.20.0-rc3
|
||||||
|
|
||||||
|
|
15
core/base.go
15
core/base.go
|
@ -553,6 +553,21 @@ func (app *BaseApp) Restart() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restart the app bootstrap as a fallback in case the
|
||||||
|
// terminate event or execve fails for some reason
|
||||||
|
defer app.Bootstrap()
|
||||||
|
|
||||||
|
// optimistically trigger the terminate event
|
||||||
|
terminateErr := app.OnTerminate().Trigger(&TerminateEvent{
|
||||||
|
App: app,
|
||||||
|
IsRestart: true,
|
||||||
|
}, func(e *TerminateEvent) error {
|
||||||
|
return e.App.ResetBootstrapState()
|
||||||
|
})
|
||||||
|
if terminateErr != nil {
|
||||||
|
return terminateErr
|
||||||
|
}
|
||||||
|
|
||||||
return syscall.Exec(execPath, os.Args, os.Environ())
|
return syscall.Exec(execPath, os.Args, os.Environ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ type BootstrapEvent struct {
|
||||||
|
|
||||||
type TerminateEvent struct {
|
type TerminateEvent struct {
|
||||||
App App
|
App App
|
||||||
|
IsRestart bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServeEvent struct {
|
type ServeEvent struct {
|
||||||
|
|
|
@ -169,8 +169,7 @@ func (pb *PocketBase) Execute() error {
|
||||||
return pb.OnTerminate().Trigger(&core.TerminateEvent{
|
return pb.OnTerminate().Trigger(&core.TerminateEvent{
|
||||||
App: pb,
|
App: pb,
|
||||||
}, func(e *core.TerminateEvent) error {
|
}, func(e *core.TerminateEvent) error {
|
||||||
e.App.ResetBootstrapState()
|
return e.App.ResetBootstrapState()
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue