MCPcopy Index your code
hub / github.com/bytebase/bytebase / Run

Method Run

backend/server/server.go:256–308  ·  view source on GitHub ↗

Run will run the server.

(ctx context.Context, port int)

Source from the content-addressed store, hash-verified

254
255// Run will run the server.
256func (s *Server) Run(ctx context.Context, port int) error {
257 ctx, cancel := context.WithCancel(ctx)
258 s.cancel = cancel
259 // runnerWG waits for all goroutines to complete.
260 s.runnerWG.Add(1)
261 go s.taskScheduler.Run(ctx, &s.runnerWG)
262 s.runnerWG.Add(1)
263 go s.schemaSyncer.Run(ctx, &s.runnerWG)
264 s.runnerWG.Add(1)
265 go s.approvalRunner.Run(ctx, &s.runnerWG)
266
267 s.runnerWG.Add(1)
268 go s.planCheckScheduler.Run(ctx, &s.runnerWG)
269
270 s.runnerWG.Add(1)
271 go s.dataCleaner.Run(ctx, &s.runnerWG)
272
273 s.runnerWG.Add(1)
274 go s.heartbeatRunner.Run(ctx, &s.runnerWG)
275
276 s.runnerWG.Add(1)
277 go s.notifyListener.Run(ctx, &s.runnerWG)
278
279 s.runnerWG.Add(1)
280 mmm := monitor.NewMemoryMonitor(s.profile)
281 go mmm.Run(ctx, &s.runnerWG)
282
283 address := fmt.Sprintf(":%d", port)
284 listener, err := net.Listen("tcp", address)
285 if err != nil {
286 return err
287 }
288
289 // Create HTTP server with H2C support (Echo v5)
290 protocols := new(http.Protocols)
291 protocols.SetHTTP1(true)
292 protocols.SetUnencryptedHTTP2(true)
293 s.httpServer = &http.Server{
294 Addr: address,
295 Handler: s.echoServer,
296 Protocols: protocols,
297 }
298
299 go func() {
300 if err := s.httpServer.Serve(listener); err != nil {
301 if !errors.Is(err, http.ErrServerClosed) {
302 slog.Error("http server listen error", log.BBError(err))
303 }
304 }
305 }()
306
307 return nil
308}
309
310// Shutdown will shut down the server.
311func (s *Server) Shutdown(ctx context.Context) error {

Callers 15

startFunction · 0.95
TestMatchSubjectPatternFunction · 0.45
TestValidateAudienceFunction · 0.45
TestValidateIssuerURLFunction · 0.45
TestNewIdentityProviderFunction · 0.45
TestNewIdentityProviderFunction · 0.45
TestMainFunction · 0.45
TestNewIdentityProviderFunction · 0.45

Calls 4

RunMethod · 0.95
NewMemoryMonitorFunction · 0.92
BBErrorFunction · 0.92
ErrorMethod · 0.45

Tested by 15

TestMatchSubjectPatternFunction · 0.36
TestValidateAudienceFunction · 0.36
TestValidateIssuerURLFunction · 0.36
TestNewIdentityProviderFunction · 0.36
TestNewIdentityProviderFunction · 0.36
TestMainFunction · 0.36
TestNewIdentityProviderFunction · 0.36