This commit is contained in:
parent
1a90f1e605
commit
4665c90c2c
4 changed files with 97 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"task-processor/internal/processor"
|
||||
"task-processor/internal/remote"
|
||||
"task-processor/internal/shared"
|
||||
"task-processor/pkg/router"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -59,6 +60,13 @@ func (app *App) Run() {
|
|||
"Number of CPUs": app.numCPUs,
|
||||
}).Debug("App settings")
|
||||
|
||||
//metrics
|
||||
mSrv := router.NewHandler(router.Deps{
|
||||
Addr: net.JoinHostPort(app.config.Metrics.Host, app.config.Metrics.Port),
|
||||
GinMode: app.config.Metrics.GinMode,
|
||||
})
|
||||
|
||||
//main
|
||||
server := newServer(app)
|
||||
apiClient := newApiClient(app.config.GrpcCfg.ApiClientHost + ":" + app.config.GrpcCfg.ApiClientPort)
|
||||
|
||||
|
|
@ -133,6 +141,13 @@ func (app *App) Run() {
|
|||
}
|
||||
}()
|
||||
|
||||
//start metrics server
|
||||
go func() {
|
||||
if err := mSrv.Run(); err != nil {
|
||||
log.WithError(err).Error("Metrics server run failed")
|
||||
}
|
||||
}()
|
||||
|
||||
//gRPC Server for status response
|
||||
go func() {
|
||||
listener, err := net.Listen("tcp", app.config.GrpcCfg.ServerHost+":"+app.config.GrpcCfg.ServerPort)
|
||||
|
|
@ -155,6 +170,10 @@ func (app *App) Run() {
|
|||
period.Stop()
|
||||
server.GracefulStop()
|
||||
cancel()
|
||||
if err := mSrv.Shutdown(ctx); err != nil {
|
||||
log.WithError(err).Error("Failed to shutdown server")
|
||||
}
|
||||
}()
|
||||
|
||||
<-ctx.Done()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue