this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add /xrpc/_health checks to bigsky and pds

+32
+15
bgs/bgs.go
··· 96 96 e.GET("/xrpc/com.atproto.sync.getHead", bgs.HandleComAtprotoSyncGetHead) 97 97 e.GET("/xrpc/com.atproto.sync.getRecord", bgs.HandleComAtprotoSyncGetRecord) 98 98 e.GET("/xrpc/com.atproto.sync.getRepo", bgs.HandleComAtprotoSyncGetRepo) 99 + e.GET("/xrpc/_health", bgs.HandleHealthCheck) 99 100 100 101 return e.Start(listen) 102 + } 103 + 104 + type HealthStatus struct { 105 + Status string `json:"status"` 106 + Message string `json:"msg,omitempty"` 107 + } 108 + 109 + func (bgs *BGS) HandleHealthCheck(c echo.Context) error { 110 + if err := bgs.db.Exec("SELECT 1").Error; err != nil { 111 + log.Errorf("healthcheck can't connect to database: %v", err) 112 + return c.JSON(500, HealthStatus{Status: "error", Message: "can't connect to database"}) 113 + } else { 114 + return c.JSON(200, HealthStatus{Status: "ok"}) 115 + } 101 116 } 102 117 103 118 type User struct {
+17
pds/server.go
··· 329 329 cfg := middleware.JWTConfig{ 330 330 Skipper: func(c echo.Context) bool { 331 331 switch c.Path() { 332 + case "/xrpc/_health": 333 + return true 332 334 case "/xrpc/com.atproto.sync.subscribeAllRepos": 333 335 return true 334 336 case "/xrpc/com.atproto.account.create": ··· 370 372 s.RegisterHandlersComAtproto(e) 371 373 s.RegisterHandlersAppBsky(e) 372 374 e.GET("/xrpc/com.atproto.sync.subscribeAllRepos", s.EventsHandler) 375 + e.GET("/xrpc/_health", s.HandleHealthCheck) 373 376 374 377 return e.Start(listen) 378 + } 379 + 380 + type HealthStatus struct { 381 + Status string `json:"status"` 382 + Message string `json:"msg,omitempty"` 383 + } 384 + 385 + func (s *Server) HandleHealthCheck(c echo.Context) error { 386 + if err := s.db.Exec("SELECT 1").Error; err != nil { 387 + log.Errorf("healthcheck can't connect to database: %v", err) 388 + return c.JSON(500, HealthStatus{Status: "error", Message: "can't connect to database"}) 389 + } else { 390 + return c.JSON(200, HealthStatus{Status: "ok"}) 391 + } 375 392 } 376 393 377 394 type User struct {