MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / StartServer

Function StartServer

rest/config.go:2171–2208  ·  view source on GitHub ↗

StartServer starts and runs the server with the given configuration. (This function never returns.)

(ctx context.Context, config *StartupConfig, sc *ServerContext)

Source from the content-addressed store, hash-verified

2169
2170// StartServer starts and runs the server with the given configuration. (This function never returns.)
2171func StartServer(ctx context.Context, config *StartupConfig, sc *ServerContext) error {
2172 if config.API.ProfileInterface != "" {
2173 // runtime.MemProfileRate = 10 * 1024
2174 base.InfofCtx(ctx, base.KeyAll, "Starting profile server on %s", base.UD(config.API.ProfileInterface))
2175 go func() {
2176 _ = http.ListenAndServe(config.API.ProfileInterface, nil)
2177 }()
2178 }
2179
2180 go sc.PostStartup()
2181
2182 if config.Unsupported.DiagnosticInterface != "" {
2183 base.ConsolefCtx(ctx, base.LevelInfo, base.KeyAll, "Starting diagnostic server on %s", config.Unsupported.DiagnosticInterface)
2184 go func() {
2185 if err := sc.Serve(ctx, config, diagnosticServer, config.Unsupported.DiagnosticInterface, createDiagnosticHandler(sc)); err != nil {
2186 base.ErrorfCtx(ctx, "Error serving the Diagnostic API: %v", err)
2187 }
2188 }()
2189 } else {
2190 base.ConsolefCtx(ctx, base.LevelInfo, base.KeyAll, "Diagnostic API not enabled - skipping.")
2191 }
2192 base.ConsolefCtx(ctx, base.LevelInfo, base.KeyAll, "Starting metrics server on %s", config.API.MetricsInterface)
2193 go func() {
2194 if err := sc.Serve(ctx, config, metricsServer, config.API.MetricsInterface, CreateMetricHandler(sc)); err != nil {
2195 base.ErrorfCtx(ctx, "Error serving the Metrics API: %v", err)
2196 }
2197 }()
2198
2199 base.ConsolefCtx(ctx, base.LevelInfo, base.KeyAll, "Starting admin server on %s", config.API.AdminInterface)
2200 go func() {
2201 if err := sc.Serve(ctx, config, adminServer, config.API.AdminInterface, CreateAdminHandler(sc)); err != nil {
2202 base.ErrorfCtx(ctx, "Error serving the Admin API: %v", err)
2203 }
2204 }()
2205
2206 base.ConsolefCtx(ctx, base.LevelInfo, base.KeyAll, "Starting server on %s ...", config.API.PublicInterface)
2207 return sc.Serve(ctx, config, publicServer, config.API.PublicInterface, CreatePublicHandler(sc))
2208}
2209
2210func sharedBucketDatabaseCheck(ctx context.Context, sc *ServerContext) (errors error) {
2211 bucketUUIDToDBContext := make(map[string][]*db.DatabaseContext, len(sc._databases))

Callers 5

StartServerWithConfigFunction · 0.85
legacyServerMainFunction · 0.85
DevTestFetchConfigManualFunction · 0.85

Calls 10

InfofCtxFunction · 0.92
UDFunction · 0.92
ConsolefCtxFunction · 0.92
ErrorfCtxFunction · 0.92
createDiagnosticHandlerFunction · 0.85
CreateMetricHandlerFunction · 0.85
CreateAdminHandlerFunction · 0.85
CreatePublicHandlerFunction · 0.85
PostStartupMethod · 0.80
ServeMethod · 0.80

Tested by 2

DevTestFetchConfigManualFunction · 0.68