mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-28 02:45:08 +08:00
## 背景 原方案使用系统 Python + pip --prefix 安装依赖到 data/dep_cache/python3, 系统 Python 环境被污染,且无法隔离不同项目的依赖。 ## 改动内容 ### 核心:Python venv 支持 - shell/start.sh: 使用 python3 -m venv 创建虚拟环境,替代 --prefix 模式 - 从 .env 文件读取 PYTHON_VENV_DIR 配置 - 首次启动自动创建 .venv,已存在则跳过 - 仅将 .venv/bin 加入 PATH 优先级,不设置 PYTHONHOME/PYTHONPATH(避免破坏 venv 机制) - .env 不再强制覆盖,仅首次从 .env.example 复制 - 启动时自动修复 task/ql 软链接指向当前部署目录 ### 后端适配 - back/config/const.ts: 新增 PYTHON_VENV_DIR 常量 - back/config/util.ts: venv 模式下跳过 pip --prefix,直接使用 venv 的 pip3 ### 开发模式支持 - shell/dev-env.sh: pnpm start 时自动 source,将 .venv/bin 加入 PATH - package.json: start:back 加入 source dev-env.sh ### 新增文件 - shell/start-simplify.sh: 精简版启动脚本(跳过系统依赖安装,适用于已预装环境的服务器) - README-NODE.md: Node.js 原生部署完整文档 ### 配置 - .env.example: 新增 PYTHON_VENV_DIR=./.venv 配置项(默认注释状态) ## 兼容性 - Docker 模式不受影响(使用独立的 docker-entrypoint.sh,走原有 --prefix 逻辑) - 未配置 PYTHON_VENV_DIR 时默认使用系统 Python(向后兼容)
88 lines
1.9 KiB
TypeScript
88 lines
1.9 KiB
TypeScript
export const LOG_END_SYMBOL = ' ';
|
||
|
||
export const TASK_COMMAND = 'task';
|
||
export const QL_COMMAND = 'ql';
|
||
|
||
export const TASK_PREFIX = `${TASK_COMMAND} `;
|
||
export const QL_PREFIX = `${QL_COMMAND} `;
|
||
|
||
export const SAMPLE_FILES = [
|
||
{
|
||
title: 'config.sample.sh',
|
||
value: 'sample/config.sample.sh',
|
||
target: 'config.sh',
|
||
},
|
||
{
|
||
title: 'notify.js',
|
||
value: 'sample/notify.js',
|
||
target: 'data/scripts/sendNotify.js',
|
||
},
|
||
{
|
||
title: 'notify.py',
|
||
value: 'sample/notify.py',
|
||
target: 'data/scripts/notify.py',
|
||
},
|
||
];
|
||
|
||
export const PYTHON_INSTALL_DIR = process.env.PYTHON_HOME;
|
||
export const PYTHON_VENV_DIR = process.env.PYTHON_VENV_DIR;
|
||
|
||
export const NotificationModeStringMap = {
|
||
0: 'gotify',
|
||
1: 'goCqHttpBot',
|
||
2: 'serverChan',
|
||
3: 'pushDeer',
|
||
4: 'bark',
|
||
5: 'chat',
|
||
6: 'telegramBot',
|
||
7: 'dingtalkBot',
|
||
8: 'weWorkBot',
|
||
9: 'weWorkApp',
|
||
10: 'aibotk',
|
||
11: 'iGot',
|
||
12: 'pushPlus',
|
||
13: 'wePlusBot',
|
||
14: 'email',
|
||
15: 'pushMe',
|
||
16: 'feishu',
|
||
17: 'webhook',
|
||
18: 'chronocat',
|
||
19: 'ntfy',
|
||
20: 'wxPusherBot',
|
||
} as const;
|
||
|
||
export const LINUX_DEPENDENCE_COMMAND: Record<
|
||
'Debian' | 'Ubuntu' | 'Alpine',
|
||
{
|
||
install: string;
|
||
uninstall: string;
|
||
info: string;
|
||
check(info: string): boolean;
|
||
}
|
||
> = {
|
||
Debian: {
|
||
install: 'sudo apt-get install -y',
|
||
uninstall: 'sudo apt-get remove -y',
|
||
info: 'sudo dpkg-query -s',
|
||
check(info: string) {
|
||
return info.includes('install ok installed');
|
||
},
|
||
},
|
||
Ubuntu: {
|
||
install: 'sudo apt-get install -y',
|
||
uninstall: 'sudo apt-get remove -y',
|
||
info: 'sudo dpkg-query -s',
|
||
check(info: string) {
|
||
return info.includes('install ok installed');
|
||
},
|
||
},
|
||
Alpine: {
|
||
install: 'apk add --no-check-certificate',
|
||
uninstall: 'apk del',
|
||
info: 'apk info -es',
|
||
check(info: string) {
|
||
return info.includes('installed');
|
||
},
|
||
},
|
||
};
|