| 11 | ) |
| 12 | |
| 13 | func (c *Controller) startHttpServer() { |
| 14 | defer func() { |
| 15 | if r := recover(); r != nil { |
| 16 | fmt.Errorf("%v", r) |
| 17 | debug.PrintStack() |
| 18 | } |
| 19 | }() |
| 20 | |
| 21 | Engine := gin.Default() |
| 22 | Engine.GET("/debug/pprof/", gin.WrapF(http.HandlerFunc(pprof.Index))) |
| 23 | Engine.GET("/debug/pprof/cmdline", gin.WrapF(http.HandlerFunc(pprof.Cmdline))) |
| 24 | Engine.GET("/debug/pprof/profile", gin.WrapF(http.HandlerFunc(pprof.Profile))) |
| 25 | Engine.GET("/debug/pprof/symbol", gin.WrapF(http.HandlerFunc(pprof.Symbol))) |
| 26 | Engine.GET("/debug/pprof/trace", gin.WrapF(http.HandlerFunc(pprof.Trace))) |
| 27 | nodes := Engine.Group("/nodes") |
| 28 | { |
| 29 | nodes.GET("/status", nodesStatus) |
| 30 | } |
| 31 | queues := Engine.Group("/queues") |
| 32 | { |
| 33 | queues.GET("/status", queueStatus) |
| 34 | queues.POST("/:id/clean", queueClean) |
| 35 | queues.POST("/:id/mute", queueMute) |
| 36 | queues.POST("/:id/unmute", queueUnMute) |
| 37 | } |
| 38 | |
| 39 | Engine.Run(GlobalConfig.HTTP_SERVER) |
| 40 | } |
| 41 | |
| 42 | func nodesStatus(c *gin.Context) { |
| 43 | c.JSON(http.StatusOK, gin.H{"nodes": controller.nodePool.Nodes}) |