This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
serve.go
54 lines (43 loc) · 1.66 KB
/
serve.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package entrypoints
import (
"context"
"github.com/flyteorg/flyteadmin/plugins"
"github.com/flyteorg/flytestdlib/profutils"
_ "net/http/pprof" // Required to serve application.
"github.com/flyteorg/flyteadmin/pkg/common"
"github.com/flyteorg/flyteadmin/pkg/server"
"github.com/flyteorg/flytestdlib/logger"
"github.com/spf13/cobra"
runtimeConfig "github.com/flyteorg/flyteadmin/pkg/runtime"
"github.com/flyteorg/flytestdlib/contextutils"
"github.com/flyteorg/flytestdlib/promutils/labeled"
)
var pluginRegistryStore = plugins.NewAtomicRegistry(plugins.NewRegistry())
// serveCmd represents the serve command
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Launches the Flyte admin server",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
// Serve profiling endpoints.
cfg := runtimeConfig.NewConfigurationProvider()
go func() {
err := profutils.StartProfilingServerWithDefaultHandlers(
ctx, cfg.ApplicationConfiguration().GetTopLevelConfig().GetProfilerPort(), nil)
if err != nil {
logger.Panicf(ctx, "Failed to Start profiling and Metrics server. Error, %v", err)
}
}()
return server.Serve(ctx, pluginRegistryStore.Load(), nil)
},
}
func init() {
// Command information
RootCmd.AddCommand(serveCmd)
RootCmd.AddCommand(secretsCmd)
// Set Keys
labeled.SetMetricKeys(contextutils.AppNameKey, contextutils.ProjectKey, contextutils.DomainKey,
contextutils.ExecIDKey, contextutils.WorkflowIDKey, contextutils.NodeIDKey, contextutils.TaskIDKey,
contextutils.TaskTypeKey, contextutils.PhaseKey, contextutils.LaunchPlanIDKey, common.ErrorKindKey, common.RuntimeTypeKey,
common.RuntimeVersionKey)
}