Files
jiang13-forum/cmd/jiang13/main.go
freefire c07d1fd2bd
Some checks failed
Docker / docker (push) Has been cancelled
feat: 新增 Docker 容器化部署,支持 Docker Hub 镜像发布
多阶段 Dockerfile、Compose、/health 探活与 JIANG13_* 环境变量;
entrypoint 自动修正 /data 卷权限,适配 1Panel 等平台;更新 README 部署文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 18:30:53 +08:00

47 lines
1016 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"fmt"
"log"
"os"
"github.com/kardianos/service"
"git.iioio.com/freefire/jiang13-forum/config"
)
// version 由构建脚本通过 -ldflags "-X main.version=..." 注入
var version = "dev"
func main() {
cfg, err := config.Parse()
if err != nil {
log.Fatalf("配置解析失败: %v", err)
}
svcCfg, err := buildServiceConfig(cfg)
if err != nil {
log.Fatalf("构建服务配置失败: %v", err)
}
prg := &program{cfg: cfg}
svc, err := service.New(prg, svcCfg)
if err != nil {
log.Fatalf("创建系统服务失败: %v", err)
}
if cfg.ServiceAction != "" {
if err := runServiceControl(svc, cfg.ServiceAction); err != nil {
fmt.Fprintf(os.Stderr, "服务操作失败 (%s): %v\n", cfg.ServiceAction, err)
os.Exit(1)
}
return
}
// 交互终端或由服务管理器拉起时均走 Run
// Windows Service / systemd 负责生命周期;前台运行时仍响应 Ctrl+C / SIGTERM
if err := svc.Run(); err != nil {
log.Fatalf("运行失败: %v", err)
}
}