Skip to content

Commit

Permalink
feat: add ui-disabled flag to run server with UI disabled (#21922)
Browse files Browse the repository at this point in the history
* feat: add `ui-disabled` flag to run server with UI disabled

* chore: update CHANGELOG
  • Loading branch information
williamhbaker authored Jul 22, 2021
1 parent 310537f commit 9b6527a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This release upgrades the project to `go` version 1.16.

Because of the version bump to `go`, the macOS build for this release requires at least version 10.12 Sierra to run.

### Features

1. [21922](https://github.com/influxdata/influxdb/pull/21922): Add `--ui-disabled` option to `influxd` to allow for running with the UI disabled.

### Bug Fixes

1. [21748](https://github.com/influxdata/influxdb/pull/21748): Rename arm rpms with yum-compatible names.
Expand Down
9 changes: 9 additions & 0 deletions cmd/influxd/launcher/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type InfluxdOpts struct {

ProfilingDisabled bool
MetricsDisabled bool
UIDisabled bool

NatsPort int
NatsMaxPayloadBytes int
Expand Down Expand Up @@ -196,6 +197,7 @@ func NewOpts(viper *viper.Viper) *InfluxdOpts {

ProfilingDisabled: false,
MetricsDisabled: false,
UIDisabled: false,

StoreType: BoltStore,
SecretStore: BoltStore,
Expand Down Expand Up @@ -561,5 +563,12 @@ func (o *InfluxdOpts) BindCliOpts() []cli.Opt {
Desc: "Don't expose metrics over HTTP at /metrics",
Default: o.MetricsDisabled,
},
// UI Config
{
DestP: &o.UIDisabled,
Flag: "ui-disabled",
Default: o.UIDisabled,
Desc: "Disable the InfluxDB UI",
},
}
}
1 change: 1 addition & 0 deletions cmd/influxd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) {

m.apibackend = &http.APIBackend{
AssetsPath: opts.AssetsPath,
UIDisabled: opts.UIDisabled,
HTTPErrorHandler: kithttp.ErrorHandler(0),
Logger: m.log,
SessionRenewDisabled: opts.SessionRenewDisabled,
Expand Down
1 change: 1 addition & 0 deletions http/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type APIHandler struct {
// an APIHandler.
type APIBackend struct {
AssetsPath string // if empty then assets are served from bindata.
UIDisabled bool // if true requests for the UI will return 404
Logger *zap.Logger
influxdb.HTTPErrorHandler
SessionRenewDisabled bool
Expand Down
4 changes: 4 additions & 0 deletions http/platform_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func NewPlatformHandler(b *APIBackend, opts ...APIHandlerOptFn) *PlatformHandler
h.RegisterNoAuthRoute("GET", "/api/v2/swagger.json")

assetHandler := static.NewAssetHandler(b.AssetsPath)
if b.UIDisabled {
b.Logger.Debug("http server running with UI disabled")
assetHandler = http.NotFoundHandler()
}

wrappedHandler := kithttp.SetCORS(h)
wrappedHandler = kithttp.SkipOptions(wrappedHandler)
Expand Down

0 comments on commit 9b6527a

Please sign in to comment.