MCPcopy
hub / github.com/cloudflare/cloudflared / handleServiceMode

Function handleServiceMode

cmd/cloudflared/main.go:198–229  ·  view source on GitHub ↗

cloudflared was started without any flags

(c *cli.Context, shutdownC chan struct{})

Source from the content-addressed store, hash-verified

196
197// cloudflared was started without any flags
198func handleServiceMode(c *cli.Context, shutdownC chan struct{}) error {
199 log := logger.CreateLoggerFromContext(c, logger.DisableTerminalLog)
200
201 // start the main run loop that reads from the config file
202 f, err := watcher.NewFile()
203 if err != nil {
204 log.Err(err).Msg("Cannot load config file")
205 return err
206 }
207
208 configPath := config.FindOrCreateConfigPath()
209 configManager, err := config.NewFileManager(f, configPath, log)
210 if err != nil {
211 log.Err(err).Msg("Cannot setup config file for monitoring")
212 return err
213 }
214 log.Info().Msgf("monitoring config file at: %s", configPath)
215
216 serviceCallback := func(t string, name string, err error) {
217 if err != nil {
218 log.Err(err).Msgf("%s service: %s encountered an error", t, name)
219 }
220 }
221 serviceManager := overwatch.NewAppManager(serviceCallback)
222
223 appService := NewAppService(configManager, serviceManager, shutdownC, log)
224 if err := appService.Run(); err != nil {
225 log.Err(err).Msg("Failed to start app service")
226 return err
227 }
228 return nil
229}

Callers 1

actionFunction · 0.85

Calls 8

RunMethod · 0.95
CreateLoggerFromContextFunction · 0.92
NewFileFunction · 0.92
FindOrCreateConfigPathFunction · 0.92
NewFileManagerFunction · 0.92
NewAppManagerFunction · 0.92
NewAppServiceFunction · 0.85
ErrMethod · 0.45

Tested by

no test coverage detected