fix(launcher): influxd inspect commands now start instantly

Lazily initialize flux, which increases startup time considerably
pull/19446/head
Stuart Carnie 2020-08-03 15:16:36 -07:00
parent 0a644dceed
commit 262023ae4a
No known key found for this signature in database
GPG Key ID: 848D9C9718D78B4F
3 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,7 @@ import (
"github.com/influxdata/influxdb/v2/pkger"
infprom "github.com/influxdata/influxdb/v2/prometheus"
"github.com/influxdata/influxdb/v2/query"
"github.com/influxdata/influxdb/v2/query/builtinlazy"
"github.com/influxdata/influxdb/v2/query/control"
"github.com/influxdata/influxdb/v2/query/fluxlang"
"github.com/influxdata/influxdb/v2/query/stdlib/influxdata/influxdb"
@ -132,6 +133,8 @@ func cmdRunE(ctx context.Context, l *Launcher) func() error {
// exit with SIGINT and SIGTERM
ctx = signals.WithStandardSignals(ctx)
builtinlazy.Initialize()
if err := l.run(ctx); err != nil {
return err
} else if !l.Running() {

View File

@ -10,7 +10,6 @@ import (
"github.com/influxdata/flux"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/cmd/influxd/launcher"
_ "github.com/influxdata/influxdb/v2/query/builtin"
_ "github.com/influxdata/influxdb/v2/v1/tsdb/engine/tsm1"
_ "github.com/influxdata/influxdb/v2/v1/tsdb/index/tsi1"
"github.com/spf13/cobra"

View File

@ -0,0 +1,20 @@
package builtinlazy
import (
"sync"
"github.com/influxdata/flux"
_ "github.com/influxdata/flux/stdlib" // Import the stdlib
_ "github.com/influxdata/influxdb/v2/query/stdlib" // Import the stdlib
)
var once sync.Once
// Initialize ensures all Flux builtins are configured and should be called
// prior to using the Flux runtime. Initialize is safe to call concurrently
// and is idempotent.
func Initialize() {
once.Do(func() {
flux.FinalizeBuiltIns()
})
}