MCPcopy
hub / github.com/writefreely/writefreely / Initialize

Function Initialize

app.go:402–446  ·  view source on GitHub ↗

Initialize loads the app configuration and initializes templates, keys, session, route handlers, and the database connection.

(apper Apper, debug bool)

Source from the content-addressed store, hash-verified

400// Initialize loads the app configuration and initializes templates, keys,
401// session, route handlers, and the database connection.
402func Initialize(apper Apper, debug bool) (*App, error) {
403 debugging = debug
404
405 apper.LoadConfig()
406
407 // Load templates
408 err := InitTemplates(apper.App().Config())
409 if err != nil {
410 return nil, fmt.Errorf("load templates: %s", err)
411 }
412
413 // Load keys and set up session
414 initKeyPaths(apper.App()) // TODO: find a better way to do this, since it's unneeded in all Apper implementations
415 err = InitKeys(apper)
416 if err != nil {
417 return nil, fmt.Errorf("init keys: %s", err)
418 }
419 apper.App().InitUpdates()
420
421 apper.App().InitSession()
422
423 apper.App().InitDecoder()
424
425 err = ConnectToDatabase(apper.App())
426 if err != nil {
427 return nil, fmt.Errorf("connect to DB: %s", err)
428 }
429
430 initActivityPub(apper.App())
431
432 if apper.App().cfg.Email.Enabled() {
433 log.Info("Starting publish jobs queue...")
434 go startPublishJobsQueue(apper.App())
435 } else {
436 log.Info("[jobs] Not starting publish jobs queue: no email provider is configured.")
437 }
438
439 // Handle local timeline, if enabled
440 if apper.App().cfg.App.LocalTimeline {
441 log.Info("Initializing local timeline...")
442 initLocalTimeline(apper.App())
443 }
444
445 return apper.App(), nil
446}
447
448func Serve(app *App, r *mux.Router) {
449 log.Info("Going to serve...")

Callers 2

serveActionFunction · 0.92
legacyActionsFunction · 0.92

Calls 14

InitTemplatesFunction · 0.85
initKeyPathsFunction · 0.85
InitKeysFunction · 0.85
ConnectToDatabaseFunction · 0.85
initActivityPubFunction · 0.85
startPublishJobsQueueFunction · 0.85
initLocalTimelineFunction · 0.85
InitUpdatesMethod · 0.80
InitSessionMethod · 0.80
InitDecoderMethod · 0.80
EnabledMethod · 0.80
LoadConfigMethod · 0.65

Tested by

no test coverage detected