MCPcopy
hub / github.com/pocketbase/pocketbase / Bootstrap

Method Bootstrap

core/base.go:391–443  ·  view source on GitHub ↗

Bootstrap initializes the application (aka. create data dir, open db connections, load settings, etc.). It will call ResetBootstrapState() if the application was already bootstrapped.

()

Source from the content-addressed store, hash-verified

389//
390// It will call ResetBootstrapState() if the application was already bootstrapped.
391func (app *BaseApp) Bootstrap() error {
392 event := &BootstrapEvent{}
393 event.App = app
394
395 err := app.OnBootstrap().Trigger(event, func(e *BootstrapEvent) error {
396 // clear resources of previous core state (if any)
397 if err := app.ResetBootstrapState(); err != nil {
398 return err
399 }
400
401 // ensure that data dir exist
402 if err := os.MkdirAll(app.DataDir(), os.ModePerm); err != nil {
403 return err
404 }
405
406 if err := app.initDataDB(); err != nil {
407 return err
408 }
409
410 if err := app.initAuxDB(); err != nil {
411 return err
412 }
413
414 if err := app.initLogger(); err != nil {
415 return err
416 }
417
418 if err := app.RunSystemMigrations(); err != nil {
419 return err
420 }
421
422 if err := app.ReloadCachedCollections(); err != nil {
423 return err
424 }
425
426 if err := app.ReloadSettings(); err != nil {
427 return err
428 }
429
430 // try to cleanup the pb_data temp directory (if any)
431 _ = os.RemoveAll(filepath.Join(app.DataDir(), LocalTempDirName))
432
433 return nil
434 })
435
436 // add a more user friendly message in case users forgot to call
437 // e.Next() as part of their bootstrap hook
438 if err == nil && !app.IsBootstrapped() {
439 app.Logger().Warn("OnBootstrap hook didn't fail but the app is still not bootstrapped - maybe missing e.Next()?")
440 }
441
442 return err
443}
444
445type closer interface {
446 Close() error

Calls 13

OnBootstrapMethod · 0.95
ResetBootstrapStateMethod · 0.95
DataDirMethod · 0.95
initDataDBMethod · 0.95
initAuxDBMethod · 0.95
initLoggerMethod · 0.95
RunSystemMigrationsMethod · 0.95
ReloadSettingsMethod · 0.95
IsBootstrappedMethod · 0.95
LoggerMethod · 0.95
TriggerMethod · 0.80