Skip to content

Commit

Permalink
server: open most HTTP endpoints later
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg committed Oct 26, 2017
1 parent a182d4c commit c884b47
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,14 @@ func (s *Server) Start(ctx context.Context) error {
// TODO(marc): when cookie-based authentication exists, apply it to all web
// endpoints.
s.mux.Handle(debugEndpoint, authorizedHandler(http.HandlerFunc(handleDebug)))
// Also throw the landing page in there. It won't work well, but it's better than a 404.
// The remaining endpoints will be opened late, when we're sure that the subsystems they
// talk to are functional.
s.mux.Handle("/", http.FileServer(&assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: ui.AssetInfo,
}))

// Filter the gossip bootstrap resolvers based on the listen and
// advertise addresses.
Expand Down Expand Up @@ -1014,20 +1022,6 @@ If problems persist, please see ` + base.DocsURL("cluster-setup-troubleshooting.
}
}

s.mux.Handle("/", http.FileServer(&assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: ui.AssetInfo,
}))

s.mux.Handle(adminPrefix, authHandler)
s.mux.Handle(ts.URLPrefix, authHandler)
s.mux.Handle(statusPrefix, authHandler)
s.mux.Handle(authPrefix, gwMux)
s.mux.Handle("/health", gwMux)
s.mux.Handle(statusVars, http.HandlerFunc(s.status.handleVars))
log.Event(ctx, "added http endpoints")

// Now that we have a monotonic HLC wrt previous incarnations of the process,
// init all the replicas. At this point *some* store has been bootstrapped or
// we're joining an existing cluster for the first time.
Expand Down Expand Up @@ -1112,6 +1106,14 @@ If problems persist, please see ` + base.DocsURL("cluster-setup-troubleshooting.

atomic.StoreInt32(&s.serveNonGossip, 1)

s.mux.Handle(adminPrefix, authHandler)
s.mux.Handle(ts.URLPrefix, authHandler)
s.mux.Handle(statusPrefix, authHandler)
s.mux.Handle(authPrefix, gwMux)
s.mux.Handle("/health", gwMux)
s.mux.Handle(statusVars, http.HandlerFunc(s.status.handleVars))
log.Event(ctx, "added http endpoints")

log.Infof(ctx, "starting %s server at %s", s.cfg.HTTPRequestScheme(), unresolvedHTTPAddr)
log.Infof(ctx, "starting grpc/postgres server at %s", unresolvedListenAddr)
log.Infof(ctx, "advertising CockroachDB node at %s", unresolvedAdvertAddr)
Expand Down

0 comments on commit c884b47

Please sign in to comment.