6050d11f27
- 创建基于 CloudWego Hertz 的 Go 微服务脚手架 - 集成 Nacos 服务注册/发现功能 - 添加 gRPC 客户端支持 - 实现环境变量配置管理 (.env.example) - 添加 HTTP 中间件 (Recovery, AccessLog, CORS) - 配置 Gitea CI/CD 构建部署流程 BREAKING CHANGE: 项目结构调整,从简单的 API 服务升级为完整的微服务架构
34 lines
707 B
Go
34 lines
707 B
Go
package main
|
|
|
|
import (
|
|
"apiServer_service/utils/httplog"
|
|
"apiServer_service/utils/logger"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func init() {
|
|
if err := godotenv.Load(".env"); err != nil {
|
|
fmt.Println("Warning: .env file not found, using system environment variables")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
redisKey := os.Getenv("ES_REDIS_KEY")
|
|
esIndexPrefix := os.Getenv("ES_INDEX_PREFIX")
|
|
|
|
logger.Info("CLI", fmt.Sprintf("httplog 上报启动 (redis_key=%s, es_index=%s-*)", redisKey, esIndexPrefix))
|
|
|
|
go httplog.Updater(redisKey, esIndexPrefix)
|
|
|
|
quit := make(chan os.Signal, 1)
|
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
<-quit
|
|
|
|
logger.Info("CLI", "正在关闭...")
|
|
}
|