vdi-cloud/terminal/kiosk-shell/src/monitor_main.cpp
宋一鸣 61127fb714 功能:实现桌面选择流程并接入 Moonlight 会话
变更详情:feat(kiosk-shell): 登录/桌面列表产品流程 + Moonlight 会话 + 看门狗进程组修复

- 登录页改为用户认证(本地演示认证,账号密码非空通过)
- 新增桌面列表页:Windows/Moonlight 可连接,Ubuntu/麒麟待分配
- 新增 DesktopService 适配层(登录/桌面列表/连接票据,后续接 API)
- 新增 MoonlightSession:QProcess 参数数组直启 moonlight-qt,退出回列表
- 状态机扩展 AUTHENTICATING / DESKTOP_LIST
- 移除开机自动 RDP,收敛为 monitor -> kiosk-shell 单一自启链
- Monitor 按进程组结束整棵进程树,修复孤儿串流进程
- vdi-moonlight 启动器新增 vsync/frame-pacing/overlay 低延迟开关
2026-10-28 20:48:12 +08:00

67 lines
1.9 KiB
C++
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.

// 看门狗 Monitor 入口
//
// 用法:vdi-kiosk-monitor -- <主进程命令行>
// 例: vdi-kiosk-monitor -- /home/armbian/vdi-terminal/bin/kiosk-shell
//
// 对应会议纪要要求:
// "必须部署独立的 Monitor(看门狗)程序监控主进程状态,
// 主进程假死或崩溃时由 Monitor 执行 kill 操作并重启"
#include <cstdio>
#include <string>
#include "monitor.h"
int main(int argc, char** argv) {
if (argc < 2) {
std::fprintf(stderr, "用法: vdi-kiosk-monitor [--verbose] -- <主进程命令行>\n");
return 2;
}
int idx = 1;
vdi::MonitorConfig config;
config.verbose = true;
while (idx < argc && std::string(argv[idx]).rfind("--", 0) == 0) {
const std::string opt = argv[idx];
if (opt == "--") {
++idx;
break;
}
if (opt == "--quiet") {
config.verbose = false;
} else if (opt == "--verbose") {
config.verbose = true;
} else if (opt == "--heartbeat-timeout" && idx + 1 < argc) {
config.heartbeatTimeoutMs = std::atoi(argv[++idx]);
} else if (opt == "--check-interval" && idx + 1 < argc) {
config.checkIntervalMs = std::atoi(argv[++idx]);
} else if (opt == "--max-restart" && idx + 1 < argc) {
config.maxRestartAttempts = std::atoi(argv[++idx]);
} else if (opt == "--heartbeat-file" && idx + 1 < argc) {
config.heartbeatFile = argv[++idx];
} else {
// 未知选项视为主进程命令行的起点
break;
}
++idx;
}
if (idx >= argc) {
std::fprintf(stderr, "缺少主进程命令行\n");
return 2;
}
// 拼出主进程命令行
std::string command;
for (int i = idx; i < argc; ++i) {
if (i > idx) {
command += " ";
}
command += argv[i];
}
vdi::Monitor monitor(config);
return monitor.run(command);
}