feat 默认模块

This commit is contained in:
2026-01-20 12:07:18 +08:00
parent a47557920c
commit 1edebb439c
10 changed files with 98 additions and 33 deletions

View File

@@ -13,6 +13,7 @@ import (
// Prometheus 普罗米修斯模块
type Prometheus struct {
DefaultModule
wg *sync.WaitGroup
server *http.Server
metricCfg *config.MetricConfig
@@ -23,7 +24,7 @@ func (m *Prometheus) Init() error {
return nil
}
func (m *Prometheus) Start() error {
func (m *Prometheus) Start(ready *sync.WaitGroup) error {
m.wg.Add(1)
go func() {
defer m.wg.Done()
@@ -31,6 +32,7 @@ func (m *Prometheus) Start() error {
Addr: fmt.Sprintf("%v:%v", m.metricCfg.Prometheus.Address, m.metricCfg.Prometheus.Port),
Handler: promhttp.Handler(),
}
ready.Done()
if err := m.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Errorf("prometheus server failed: %v", err.Error())
}