Merge pull request #4470 from influxdata/er-perf
Improve asset loading performance on low power devicespull/4478/head
commit
6fce4418a3
|
@ -25,6 +25,7 @@
|
|||
1. [#4449](https://github.com/influxdata/chronograf/pull/4449): Add ability to use single stat graph visualizations for flux query
|
||||
1. [#4454](https://github.com/influxdata/chronograf/pull/4454): Save log line wrap/truncate preference
|
||||
1. [#4461](https://github.com/influxdata/chronograf/pull/4461): Add ability to use table graph visualizations for flux query
|
||||
1. [#4470](https://github.com/influxdata/chronograf/pull/4470): Add option to disable gzip compression
|
||||
|
||||
|
||||
### UI Improvements
|
||||
|
|
|
@ -33,6 +33,7 @@ type MuxOpts struct {
|
|||
StatusFeedURL string // JSON Feed URL for the client Status page News Feed
|
||||
CustomLinks map[string]string // Any custom external links for client's User menu
|
||||
PprofEnabled bool // Mount pprof routes for profiling
|
||||
DisableGZip bool // Optionally disable gzip.
|
||||
}
|
||||
|
||||
// NewMux attaches all the route handlers; handler returned servers chronograf.
|
||||
|
@ -45,16 +46,20 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
|
|||
Logger: opts.Logger,
|
||||
})
|
||||
|
||||
// Prefix any URLs found in the React assets with any configured basepath
|
||||
prefixedAssets := NewDefaultURLPrefixer(opts.Basepath, assets, opts.Logger)
|
||||
if opts.Basepath != "" {
|
||||
// Prefix any URLs found in the React assets with any configured basepath
|
||||
assets = NewDefaultURLPrefixer(opts.Basepath, assets, opts.Logger)
|
||||
}
|
||||
|
||||
// Compress the assets with gzip if an accepted encoding
|
||||
compressed := gziphandler.GzipHandler(prefixedAssets)
|
||||
if !opts.DisableGZip {
|
||||
assets = gziphandler.GzipHandler(assets)
|
||||
}
|
||||
|
||||
// The react application handles all the routing if the server does not
|
||||
// know about the route. This means that we never have unknown routes on
|
||||
// the server.
|
||||
hr.NotFound = compressed
|
||||
hr.NotFound = assets
|
||||
|
||||
var router chronograf.Router = hr
|
||||
|
||||
|
|
|
@ -38,8 +38,9 @@ func init() {
|
|||
|
||||
// Server for the chronograf API
|
||||
type Server struct {
|
||||
Host string `long:"host" description:"The IP to listen on" default:"0.0.0.0" env:"HOST"`
|
||||
Port int `long:"port" description:"The port to listen on for insecure connections, defaults to a random value" default:"8888" env:"PORT"`
|
||||
Host string `long:"host" description:"The IP to listen on" default:"0.0.0.0" env:"HOST"`
|
||||
Port int `long:"port" description:"The port to listen on for insecure connections, defaults to a random value" default:"8888" env:"PORT"`
|
||||
DisableGZip bool `long:"disable-gzip" description:"Disables gzip compression, even if client requests it. Useful if running on a low-cpu device" env:"DISABLE_GZIP"`
|
||||
|
||||
PprofEnabled bool `long:"pprof-enabled" description:"Enable the /debug/pprof/* HTTP routes" env:"PPROF_ENABLED"`
|
||||
|
||||
|
@ -376,6 +377,7 @@ func (s *Server) Serve(ctx context.Context) error {
|
|||
StatusFeedURL: s.StatusFeedURL,
|
||||
CustomLinks: s.CustomLinks,
|
||||
PprofEnabled: s.PprofEnabled,
|
||||
DisableGZip: s.DisableGZip,
|
||||
}, service)
|
||||
|
||||
// Add chronograf's version header to all requests
|
||||
|
|
Loading…
Reference in New Issue