Files
jiang13-forum/cmd/jiang13/main.go
freefire 95c2154087 feat: 可选社区上报与官方精选展柜
默认关闭,仪表盘一键开关;枢纽由运维配置收报,人工精选后展示于 /showcase。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 04:22:59 +08:00

49 lines
1.1 KiB
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"
appsvc "git.iioio.com/freefire/jiang13-forum/service"
)
// version 由构建脚本通过 -ldflags "-X main.version=..." 注入
var version = "dev"
func main() {
appsvc.SetAppVersion(version)
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)
}
}