MCPcopy Index your code
hub / github.com/rilldata/rill / StartCmd

Function StartCmd

cli/cmd/admin/start.go:119–469  ·  view source on GitHub ↗

StartCmd starts an admin server. It only allows configuration using environment variables.

(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

117
118// StartCmd starts an admin server. It only allows configuration using environment variables.
119func StartCmd(ch *cmdutil.Helper) *cobra.Command {
120 startCmd := &cobra.Command{
121 Use: "start [jobs|server|worker]",
122 Short: "Start admin service",
123 Args: cobra.MaximumNArgs(1),
124 Run: func(cmd *cobra.Command, args []string) {
125 // Load .env (note: fails silently if .env has errors)
126 _ = godotenv.Load()
127
128 // Init config
129 var conf Config
130 err := envconfig.Process("rill_admin", &conf)
131 if err != nil {
132 fmt.Printf("failed to load config: %s\n", err.Error())
133 os.Exit(1)
134 }
135
136 // Init logger
137 cfg := zap.NewProductionConfig()
138 cfg.Level.SetLevel(conf.LogLevel)
139 cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
140 logger, err := cfg.Build()
141 if err != nil {
142 fmt.Printf("error: failed to create logger: %s\n", err.Error())
143 os.Exit(1)
144 }
145
146 // Let ExternalGRPCURL default to ExternalURL, unless ExternalURL is itself the default.
147 if conf.ExternalGRPCURL == "" {
148 conf.ExternalGRPCURL = conf.ExternalURL
149 }
150
151 // Validate frontend and external URLs
152 _, err = url.Parse(conf.FrontendURL)
153 if err != nil {
154 logger.Fatal("invalid frontend URL", zap.Error(err))
155 }
156 _, err = url.Parse(conf.ExternalURL)
157 if err != nil {
158 logger.Fatal("invalid external URL", zap.Error(err))
159 }
160 _, err = url.Parse(conf.ExternalGRPCURL)
161 if err != nil {
162 logger.Fatal("invalid external grpc URL", zap.Error(err))
163 }
164
165 // Init observability
166 shutdown, err := observability.Start(cmd.Context(), logger, &observability.Options{
167 MetricsExporter: conf.MetricsExporter,
168 TracesExporter: conf.TracesExporter,
169 ServiceName: "admin-server",
170 ServiceVersion: ch.Version.String(),
171 })
172 if err != nil {
173 logger.Fatal("error starting observability", zap.Error(err))
174 }
175 defer func() {
176 // Allow 10 seconds to gracefully shutdown observability

Callers 1

AdminCmdFunction · 0.70

Calls 15

CloseMethod · 0.95
WithServiceNameMethod · 0.95
WithServiceVersionMethod · 0.95
WithIsDevMethod · 0.95
StartFunction · 0.92
NewNoopClientFunction · 0.92
NewKafkaSinkFunction · 0.92
NewClientFunction · 0.92
NewIssuerFunction · 0.92
NewSMTPSenderFunction · 0.92
NewConsoleSenderFunction · 0.92
NewFunction · 0.92

Tested by

no test coverage detected