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

Function StartCmd

cli/cmd/runtime/start.go:110–305  ·  view source on GitHub ↗

StartCmd starts a stand-alone runtime server. It only allows configuration using environment variables.

(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

108
109// StartCmd starts a stand-alone runtime server. It only allows configuration using environment variables.
110func StartCmd(ch *cmdutil.Helper) *cobra.Command {
111 startCmd := &cobra.Command{
112 Use: "start",
113 Short: "Start stand-alone runtime server",
114 Run: func(cmd *cobra.Command, args []string) {
115 // Load .env (note: fails silently if .env has errors)
116 _ = godotenv.Load()
117
118 // Init config
119 var conf Config
120 err := envconfig.Process("rill_runtime", &conf)
121 if err != nil {
122 fmt.Printf("failed to load config: %s\n", err.Error())
123 os.Exit(1)
124 }
125
126 // Init logger
127 cfg := zap.NewProductionConfig()
128 cfg.Level.SetLevel(conf.LogLevel)
129 cfg.EncoderConfig.NameKey = zapcore.OmitKey
130 cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
131 logger, err := cfg.Build()
132 if err != nil {
133 fmt.Printf("error: failed to create logger: %s\n", err.Error())
134 os.Exit(1)
135 }
136
137 // Init email client
138 var sender email.Sender
139 if conf.EmailSMTPHost != "" {
140 sender, err = email.NewSMTPSender(&email.SMTPOptions{
141 SMTPHost: conf.EmailSMTPHost,
142 SMTPPort: conf.EmailSMTPPort,
143 SMTPUsername: conf.EmailSMTPUsername,
144 SMTPPassword: conf.EmailSMTPPassword,
145 FromEmail: conf.EmailSenderEmail,
146 FromName: conf.EmailSenderName,
147 BCC: conf.EmailBCC,
148 })
149 } else {
150 sender, err = email.NewConsoleSender(logger, conf.EmailSenderEmail, conf.EmailSenderName)
151 }
152 if err != nil {
153 logger.Fatal("error creating email sender", zap.Error(err))
154 }
155 emailClient := email.New(sender)
156
157 // Parse session keys as hex strings
158 keyPairs := make([][]byte, len(conf.SessionKeyPairs))
159 for idx, keyHex := range conf.SessionKeyPairs {
160 key, err := hex.DecodeString(keyHex)
161 if err != nil {
162 logger.Fatal("failed to parse session key from hex string to bytes")
163 }
164 keyPairs[idx] = key
165 }
166
167 // Init observability

Callers 1

RuntimeCmdFunction · 0.70

Calls 15

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

Tested by

no test coverage detected