forked from fish2018/pansou
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
61 lines (49 loc) · 1.29 KB
/
main.go
File metadata and controls
61 lines (49 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"log"
"pansou/api"
"pansou/config"
"pansou/util"
)
func main() {
// 初始化配置
config.Init()
// 初始化HTTP客户端
util.InitHTTPClient()
// 设置路由
router := api.SetupRouter()
// 获取端口配置
port := config.AppConfig.Port
// 启动服务器
fmt.Printf("服务器启动在 http://localhost:%s\n", port)
// 输出代理信息
if config.AppConfig.UseProxy {
fmt.Printf("使用SOCKS5代理: %s\n", config.AppConfig.ProxyURL)
} else {
fmt.Println("未使用代理")
}
// 输出缓存信息
if config.AppConfig.CacheEnabled {
fmt.Printf("缓存已启用: 路径=%s, 最大大小=%dMB, TTL=%d分钟\n",
config.AppConfig.CachePath,
config.AppConfig.CacheMaxSizeMB,
config.AppConfig.CacheTTLMinutes)
} else {
fmt.Println("缓存已禁用")
}
// 输出压缩信息
if config.AppConfig.EnableCompression {
fmt.Printf("响应压缩已启用: 最小压缩大小=%d字节\n",
config.AppConfig.MinSizeToCompress)
} else {
fmt.Println("响应压缩已禁用")
}
// 输出GC配置信息
fmt.Printf("GC配置: 触发阈值=%d%%, 内存优化=%v\n",
config.AppConfig.GCPercent,
config.AppConfig.OptimizeMemory)
if err := router.Run(":" + port); err != nil {
log.Fatalf("启动服务器失败: %v", err)
}
}