mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
[优化] 修复 docker
This commit is contained in:
@@ -23,12 +23,17 @@ func printHelp() {
|
||||
fmt.Println("Usage: openflare [--port <port>] [--log-dir <log directory>] [--version] [--help]")
|
||||
}
|
||||
|
||||
func init() {
|
||||
// ParseFlags 在命令行参数被任何 import 链上的 init() 误解析之前,
|
||||
// 由各 binary 的 main() 显式调用一次。openflare_server 与 openflare-relay
|
||||
// 共用 flag.CommandLine,必须先注册各自的 flag 再调用本函数。
|
||||
// 测试场景(go test)下不会执行本函数,单元测试可直接跳过命令行解析。
|
||||
func ParseFlags() {
|
||||
executableName := strings.ToLower(filepath.Base(os.Args[0]))
|
||||
isTest := strings.Contains(executableName, ".test") || flag.Lookup("test.v") != nil
|
||||
if !isTest {
|
||||
flag.Parse()
|
||||
if isTest {
|
||||
return
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
if *PrintVersion {
|
||||
fmt.Println(Version)
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"context"
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-contrib/sessions/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log/slog"
|
||||
"openflare/common"
|
||||
_ "openflare/docs"
|
||||
@@ -19,6 +15,11 @@ import (
|
||||
"openflare/utils/geoip"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-contrib/sessions/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//go:embed all:web/build
|
||||
@@ -41,6 +42,7 @@ var indexPage []byte
|
||||
// @name X-Agent-Token
|
||||
// @description Agent API 使用节点专属 Agent Token 或全局 Discovery Token
|
||||
func main() {
|
||||
common.ParseFlags()
|
||||
common.SetupGinLog()
|
||||
slog.Info("OpenFlare started", "version", common.Version)
|
||||
if os.Getenv("GIN_MODE") != "debug" {
|
||||
|
||||
Reference in New Issue
Block a user