fix(launcher): influxd inspect commands now start instantly
Lazily initialize flux, which increases startup time considerablypull/19446/head
parent
0a644dceed
commit
262023ae4a
|
@ -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() {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue