605c0079eb
* skeleton lifecycle * bare minimum to satisfy mm-server import * added boards_imports.go * move boards_imports.go to correct package * bump mmserver version; remove replace in go.mod; use module workspaces; remove logger service * rename product.go --> boards.go * add FileInfoStore and Cloud services for product; create minimal pluginAPI interfaces for all packages * rename Boards -> BoardsProduct * compile success * remove hooks service; guard for nil BoardsApp * update to latest mmserver ver * upgrade mmserver to master tip * upgrade mmserver to master tip * bump plugin-api to master tip * fix users service * fix OnActivate crash; normalize AppError returns * fileBackend interface for server/app * feature flag * bump mmserver version * fix linter errors * make go.work when linting * fix go.work creation for CI * add execute flag for script * fix more linter errors * always create a go.work * fix ci go.work * OS agnostic go.work generator * fix path * fix path again * partially disable cypress test * fix case Id --> ID * bump mmserver version * include in go.work for dev * addressed review comments. Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
37 lines
928 B
Go
37 lines
928 B
Go
package metrics
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
)
|
|
|
|
// Service prometheus to run the server.
|
|
type Service struct {
|
|
*http.Server
|
|
}
|
|
|
|
// NewMetricsServer factory method to create a new prometheus server.
|
|
func NewMetricsServer(address string, metricsService *Metrics, logger mlog.LoggerIFace) *Service {
|
|
return &Service{
|
|
&http.Server{
|
|
Addr: address,
|
|
Handler: promhttp.HandlerFor(metricsService.registry, promhttp.HandlerOpts{
|
|
ErrorLog: logger.StdLogger(mlog.LvlError),
|
|
}),
|
|
},
|
|
}
|
|
}
|
|
|
|
// Run will start the prometheus server.
|
|
func (h *Service) Run() error {
|
|
return errors.Wrap(h.Server.ListenAndServe(), "prometheus ListenAndServe")
|
|
}
|
|
|
|
// Shutdown will shutdown the prometheus server.
|
|
func (h *Service) Shutdown() error {
|
|
return errors.Wrap(h.Server.Close(), "prometheus Close")
|
|
}
|