MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / startServer

Function startServer

cmd/server.go:259–291  ·  view source on GitHub ↗
(router *gin.Engine, port string)

Source from the content-addressed store, hash-verified

257}
258
259func startServer(router *gin.Engine, port string) error {
260 server := &http.Server{
261 Addr: ":" + port,
262 Handler: router,
263 }
264
265 // Start server in goroutine
266 go func() {
267 logrus.Infof("Server started on port %s", port)
268 if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
269 logrus.Fatalf("Server error: %v", err)
270 }
271 }()
272
273 // Wait for interrupt signal
274 quit := make(chan os.Signal, 1)
275 signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
276 <-quit
277
278 logrus.Info("Shutting down server...")
279
280 // Give outstanding requests 30 seconds to complete
281 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
282 defer cancel()
283
284 if err := server.Shutdown(ctx); err != nil {
285 logrus.Errorf("Server forced to shutdown: %v", err)
286 return err
287 }
288
289 logrus.Info("Server exited gracefully")
290 return nil
291}
292
293// Renamed from initializeObservability to better reflect its purpose
294func initializeTelemetryAndObservability(ctx context.Context, cfg *config.Configuration) (posthog.Client, func(context.Context) error, error) {

Callers 1

serverCommandsFunction · 0.85

Calls 1

InfoMethod · 0.45

Tested by

no test coverage detected