MCPcopy
hub / github.com/pocketbase/pocketbase / Execute

Method Execute

pocketbase.go:179–215  ·  view source on GitHub ↗

Execute initializes the application (if not already) and executes the pb.RootCmd with graceful shutdown support. This method differs from pb.Start() by not registering the default system commands!

()

Source from the content-addressed store, hash-verified

177// This method differs from pb.Start() by not registering the default
178// system commands!
179func (pb *PocketBase) Execute() error {
180 if !pb.skipBootstrap() {
181 if err := pb.Bootstrap(); err != nil {
182 return err
183 }
184 }
185
186 done := make(chan bool, 1)
187
188 // listen for interrupt signal to gracefully shutdown the application
189 go func() {
190 sigch := make(chan os.Signal, 1)
191 signal.Notify(sigch, os.Interrupt, syscall.SIGTERM)
192 <-sigch
193
194 done <- true
195 }()
196
197 // execute the root command
198 go func() {
199 // note: leave to the commands to decide whether to print their error
200 pb.RootCmd.Execute()
201
202 done <- true
203 }()
204
205 <-done
206
207 // trigger cleanups
208 //
209 // @todo consider skipping and just call the finalizer in case OnTerminate was already invoked manually?
210 event := new(core.TerminateEvent)
211 event.App = pb
212 return pb.OnTerminate().Trigger(event, func(e *core.TerminateEvent) error {
213 return e.App.ResetBootstrapState()
214 })
215}
216
217// eagerParseFlags parses the global app flags before calling pb.RootCmd.Execute().
218// so we can have all PocketBase flags ready for use on initialization.

Callers 15

StartMethod · 0.95
createTestDBFunction · 0.80
TestLikeParamsWrappingFunction · 0.80
RenderMethod · 0.80
resolveTemplateContentFunction · 0.80
TestReloadSettingsFunction · 0.80
sendSystemAlertFunction · 0.80
registerBaseHooksMethod · 0.80

Calls 5

skipBootstrapMethod · 0.95
TriggerMethod · 0.80
BootstrapMethod · 0.65
OnTerminateMethod · 0.65
ResetBootstrapStateMethod · 0.65