MCPcopy
hub / github.com/pocketbase/pocketbase / Restart

Method Restart

core/base.go:755–781  ·  view source on GitHub ↗

Restart restarts (aka. replaces) the current running application process. NB! It relies on execve which is supported only on UNIX based systems.

()

Source from the content-addressed store, hash-verified

753//
754// NB! It relies on execve which is supported only on UNIX based systems.
755func (app *BaseApp) Restart() error {
756 if runtime.GOOS == "windows" {
757 return errors.New("restart is not supported on windows")
758 }
759
760 execPath, err := os.Executable()
761 if err != nil {
762 return err
763 }
764
765 event := &TerminateEvent{}
766 event.App = app
767 event.IsRestart = true
768
769 return app.OnTerminate().Trigger(event, func(e *TerminateEvent) error {
770 _ = e.App.ResetBootstrapState()
771
772 // attempt to restart the bootstrap process in case execve returns an error for some reason
773 defer func() {
774 if err := e.App.Bootstrap(); err != nil {
775 app.Logger().Error("Failed to rebootstrap the application after failed app.Restart()", "error", err)
776 }
777 }()
778
779 return execve(execPath, os.Args, os.Environ())
780 })
781}
782
783// RunSystemMigrations applies all new migrations registered in the [core.SystemMigrations] list.
784func (app *BaseApp) RunSystemMigrations() error {

Callers

nothing calls this directly

Calls 7

OnTerminateMethod · 0.95
LoggerMethod · 0.95
TriggerMethod · 0.80
execveFunction · 0.70
ResetBootstrapStateMethod · 0.65
BootstrapMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected