# process_monitor **Repository Path**: mmlya/process_monitor ## Basic Information - **Project Name**: process_monitor - **Description**: 个人项目进程监控面板(本机 localhost) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-02 - **Last Updated**: 2026-09-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Process Monitor 本机个人项目进程面板:用 `projects.yaml` 白名单登记项目,在网页上查看状态并启停。支持 Ubuntu(systemd user/system)、macOS(launchd)以及通用进程/npm 项目。 默认监听 `0.0.0.0:3920`(本机 `127.0.0.1` 与局域网 IP 均可访问)。面板无鉴权,勿暴露到公网;若只需本机访问可设 `HOST=127.0.0.1`。 ## 要求 - Node.js 20+ - Linux:`systemctl --user` 的 user unit;system 级需配置 sudo 密码 - macOS:可选 `~/Library/LaunchAgents` 下的 LaunchAgent ## 安装与启动 ### 一键安装(推荐) 克隆后在项目根目录执行(自动识别 Linux / macOS): ```bash cd /path/to/process_monitor chmod +x deploy/*.sh ./deploy/install.sh ``` | 平台 | 安装内容 | |------|----------| | **Linux** | `npm install` + 用户级 systemd(`~/.config/systemd/user/process_monitor.service`)并启动 | | **macOS** | `npm install` + LaunchAgent(`~/Library/LaunchAgents/com.user.process-monitor.plist`)并启动 | 浏览器打开:http://127.0.0.1:3920 (局域网可用本机 IP) 常用命令: ```bash # Linux systemctl --user status process_monitor journalctl --user -u process_monitor -f # macOS launchctl print gui/$(id -u)/com.user.process-monitor tail -f ~/Library/Logs/process-monitor.log # 卸载开机自启(保留源码与 projects.yaml) ./deploy/uninstall.sh ``` 也可分平台直接调用:`./deploy/install-linux.sh` / `./deploy/install-macos.sh`。 仅安装依赖、不立刻启动服务:`START_NOW=0 ./deploy/install.sh`。 若尚无 `projects.yaml`,安装脚本会从 `projects.example.yaml` 生成一份空配置。 ### 手动前台运行 ```bash npm install npm start # 或 ./deploy/run.sh ``` 开发模式(改代码自动重启): ```bash npm run dev ``` 环境变量: | 变量 | 默认 | 说明 | |------|------|------| | `HOST` | `0.0.0.0` | 绑定地址;`0.0.0.0` 允许本机+局域网,`127.0.0.1` 仅本机 | | `PORT` | `3920` | 端口 | | `PROJECTS_CONFIG` | 项目根目录 `projects.yaml` | 配置路径 | | `PROCESS_MONITOR_SUDO_PASSWORD` | — | 可覆盖文件中的 sudo 密码 | ## 配置 `projects.yaml` ```yaml projects: # Ubuntu user systemd - id: hermes-agent name: Hermes Agent type: systemd unit: hermes-gateway.service scope: user # system 级(启停需 sudo) - id: ditabooktrans name: DitaBookTrans type: systemd unit: ditabooktrans.service scope: system # macOS LaunchAgent - id: hermes-agent-mac name: Hermes Agent type: launchd label: com.user.hermes-agent # plist: /Users/you/Library/LaunchAgents/com.user.hermes-agent.plist # 可选 # 通用进程 / npm - id: hermes-web-ui name: Hermes Web UI type: process cwd: /path/to/hermes-web-ui start_cmd: hermes-web-ui start --port 8647 --no-open stop_cmd: hermes-web-ui stop # 可选 port: 8647 # 强烈建议:用端口判定运行 url: http://127.0.0.1:8647 # 可选:卡片网页直达 match: hermes-web-ui # 可选,PID 丢失时的命令行兜底 match_exclude: # 可选,匹配时排除子串 - mcp_stdio_watchdog ``` 改完配置后可在面板「更多 → 重载配置」,或调用 `POST /api/reload`。面板「配置 / 添加」会原子写回 YAML。 ### 字段说明 | 字段 | 适用类型 | 说明 | |------|----------|------| | `id` | 全部 | 唯一标识 | | `name` | 全部 | 显示名 | | `type` | 全部 | `systemd` / `launchd` / `process` | | `unit` | systemd | 如 `foo.service` | | `scope` | systemd | `user`(默认)或 `system` | | `label` | launchd | LaunchAgent label | | `plist` | launchd | plist 路径;默认 `~/Library/LaunchAgents/