core: 移除 init.txt 向后兼容,仅支持 services.yaml

- InitParser: 移除 parseTxt(),load() 不再回退 init.txt
- pmc_mtd: parse_self_init_list 移除 TXT 分支,非 .yaml 文件报错退出
- main.cpp: --help 中 -i 参数描述移除 .txt
- Makefile: install/uninstall 移除 init.txt 拷贝/删除
- services.yaml: 头注释移除 init.txt 相关措辞
- 删除 init.txt 文件
- README (core + 项目根): 全部 init.txt 引用替换为 services.yaml
- core README: 补全 liblogc/yaml-cpp 依赖声明,修正文件结构
This commit is contained in:
qing committed 2026-08-10 05:39:00 +00:00
1 parent f041bf284b
commit b0d71a4c58
9 files changed
+53 -119

No files matched your search

+1 -40
View File
@@ -25,21 +25,13 @@ std::vector<ServiceConfig> InitParser::load(const std::string& dir) {
namespace fs = std::filesystem;
auto yaml_path = fs::path(dir) / "services.yaml";
auto txt_path = fs::path(dir) / "init.txt";
/* 优先 services.yaml */
if (fs::exists(yaml_path)) {
std::cerr << "[InitParser] 使用 services.yaml: " << yaml_path << std::endl;
return parseYaml(yaml_path.string());
}
/* 回退 init.txt */
if (fs::exists(txt_path)) {
std::cerr << "[InitParser] 回退 init.txt: " << txt_path << std::endl;
return parseTxt(txt_path.string());
}
std::cerr << "[InitParser] 未找到 services.yaml 或 init.txt 于 " << dir << std::endl;
std::cerr << "[InitParser] 未找到 services.yaml 于 " << dir << std::endl;
return {};
}
@@ -95,37 +87,6 @@ std::vector<ServiceConfig> InitParser::parseYaml(const std::string& path) {
return result;
}
std::vector<ServiceConfig> InitParser::parseTxt(const std::string& path) {
std::vector<ServiceConfig> result;
std::ifstream file(path);
if (!file.is_open()) {
std::cerr << "[InitParser] 无法打开 init.txt: " << path << std::endl;
return {};
}
std::string line;
while (std::getline(file, line)) {
/* 去除注释(# 之后的内容) */
auto pos = line.find('#');
if (pos != std::string::npos)
line = line.substr(0, pos);
/* trim 空白 */
auto first = line.find_first_not_of(" \t\r\n");
if (first == std::string::npos)
continue; /* 空行 */
auto last = line.find_last_not_of(" \t\r\n");
line = line.substr(first, last - first + 1);
ServiceConfig svc;
svc.cmd = line;
/* init.txt 模式下 name/args/env/depends_on/sleep_before 均为空/默认 */
result.push_back(std::move(svc));
}
std::cerr << "[InitParser] init.txt 解析完成,共 " << result.size() << " 个服务" << std::endl;
return result;
}
} // namespace qing::registry