feat(config):支持 compose 本地配置切换

This commit is contained in:
leonincs
2026-04-21 15:33:33 +08:00
parent 96c8ee51e6
commit 33d6816ac6
4 changed files with 47 additions and 10 deletions

View File

@@ -9,14 +9,18 @@ import (
rediscache "feedsystem_video_go/internal/middleware/redis"
"feedsystem_video_go/internal/observability"
"log"
"os"
"strconv"
"time"
)
func main() {
// 加载配置
log.Printf("Loading config from configs/config.yaml")
const configPath = "configs/config.yaml"
configPath := os.Getenv("CONFIG_PATH")
if configPath == "" {
configPath = "configs/config.yaml"
}
log.Printf("Loading config from %s", configPath)
cfg, usedDefault, err := config.LoadLocalDev(configPath)
if err != nil {
log.Fatalf("Failed to load config: %v", err)

View File

@@ -10,7 +10,6 @@ import (
"feedsystem_video_go/internal/video"
"feedsystem_video_go/internal/worker"
"log"
"os"
"os/signal"
"strconv"
@@ -40,7 +39,10 @@ const (
func main() {
// 加载配置
const configPath = "configs/config.yaml"
configPath := os.Getenv("CONFIG_PATH")
if configPath == "" {
configPath = "configs/config.yaml"
}
log.Printf("Loading config from %s", configPath)
cfg, usedDefault, err := config.LoadLocalDev(configPath)
if err != nil {

View File

@@ -0,0 +1,27 @@
server:
port: 8080
database:
host: localhost
port: 3307
user: root
password: 123456
dbname: feedsystem
redis:
host: localhost
port: 6379
password: 123456
db: 0
rabbitmq:
host: localhost
port: 5672
username: admin
password: password123
observability:
pprof:
enabled: true
api_addr: localhost:6060
worker_addr: localhost:6061