feat(observability): 为 API 和 worker 增加独立 pprof 诊断端口

This commit is contained in:
tangerineyu
2026-03-25 19:27:33 +08:00
parent 21efce6049
commit 9a0ba45a51
7 changed files with 144 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ type Config struct {
Database DatabaseConfig `yaml:"database"`
Redis RedisConfig `yaml:"redis"`
RabbitMQ RabbitMQConfig `yaml:"rabbitmq"`
ObservabilityConfig ObservabilityConfig `yaml:"observability"`
}
type ServerConfig struct {
@@ -40,6 +41,14 @@ type RabbitMQConfig struct {
Password string `yaml:"password"`
}
type ObservabilityConfig struct {
Pprof PprofConfig `yaml:"pprof"`
}
type PprofConfig struct {
Enabled bool `yaml:"enabled"`
ApiAddr string `yaml:"api_addr"`
WorkerAddr string `yaml:"worker_addr"`
}
func Load(filename string) (Config, error) {
data, err := os.ReadFile(filename)
if err != nil {
@@ -90,5 +99,12 @@ func DefaultLocalConfig() Config {
Username: "admin",
Password: "password123",
},
ObservabilityConfig: ObservabilityConfig{
Pprof: PprofConfig{
Enabled: true,
ApiAddr: "localhost:6060",
WorkerAddr: "localhost:6061",
},
},
}
}