up
This commit is contained in:
@@ -103,16 +103,10 @@ prometheus:
|
||||
|
||||
// loadConfig 从 savedata/config.yml 加载配置
|
||||
func loadConfig() error {
|
||||
configPath := filepath.Join("savedata", "config.yml")
|
||||
|
||||
// 检查配置文件是否存在
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
return fmt.Errorf("config file not found: %s", configPath)
|
||||
if err := config.LoadFromSavedata(); err != nil {
|
||||
return fmt.Errorf("failed to load config: %v", err)
|
||||
}
|
||||
|
||||
// TODO: 解析 YAML 配置文件并应用到 config 包
|
||||
// 这里暂时只是检查文件存在,后续可以添加 YAML 解析逻辑
|
||||
log.Printf("Loading config from: %s", configPath)
|
||||
log.Printf("Config loaded successfully from savedata/config.yml")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -130,8 +124,8 @@ func main() {
|
||||
// ---- 命令行参数 ----
|
||||
// --storage:存储根目录路径,默认使用 config.StoragePath
|
||||
storageDir := flag.String("storage", config.StoragePath, "path to savedata directory")
|
||||
// --entry:BFS 爬取的起始 URL,默认使用 config.EntryURL(维基百科中文首页)
|
||||
entryURL := flag.String("entry", config.EntryURL, "BFS crawl entry URL")
|
||||
// --entry:BFS 爬取的起始 URL,默认使用 config.EntryURL()(维基百科中文首页)
|
||||
entryURL := flag.String("entry", config.EntryURL(), "BFS crawl entry URL")
|
||||
// --stopwords:屏蔽词 JSON 文件路径
|
||||
stopWords := flag.String("stopwords", "../data/标点符号.json", "path to stop-words JSON")
|
||||
flag.Parse()
|
||||
@@ -161,7 +155,7 @@ func main() {
|
||||
// ---- 4. 搜索服务器(默认 :80):对外提供搜索 API,同时内嵌收获服务(统一端口)
|
||||
searchSrv := search.New(db, infoSvc, anal)
|
||||
go func() {
|
||||
addr := fmt.Sprintf(":%d", config.SearchServerPort)
|
||||
addr := fmt.Sprintf(":%d", config.SearchServerPort())
|
||||
if err := searchSrv.ListenAndServe(addr); err != nil {
|
||||
log.Fatalf("[search] fatal: %v", err)
|
||||
}
|
||||
@@ -175,7 +169,7 @@ func main() {
|
||||
// 从 info 服务获取繁荣表快照,用于调度优先级决策
|
||||
prosperMap := infoSvc.ProsperMap()
|
||||
crawl := crawler.New(db, anal, prosperMap)
|
||||
go crawl.Run(*entryURL, config.MaxEpoch)
|
||||
go crawl.Run(*entryURL, config.MaxEpoch())
|
||||
|
||||
log.Println("all modules started — press Ctrl-C to stop")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user