@oxiaom/adoremix 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/paths.js +23 -0
- package/src/runner/spawn.js +13 -0
package/package.json
CHANGED
package/src/paths.js
CHANGED
|
@@ -37,7 +37,30 @@ function loadNative() {
|
|
|
37
37
|
return _native;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// 检测已安装的工作目录:扫描常见路径找 .adoremix-installed 标记。
|
|
41
|
+
// 这样 start/restart/stop 等命令在未显式传 --workdir 时,也会用到实际安装目录,
|
|
42
|
+
// 避免 root 装了 /opt/adoremix 后用非 root 跑命令时解析到别处、找不到 .Adore.db/config.ini。
|
|
43
|
+
function detectInstalledWorkdir() {
|
|
44
|
+
const candidates = [];
|
|
45
|
+
if (process.platform === 'win32') {
|
|
46
|
+
candidates.push(path.join(process.env.PROGRAMDATA || 'C:\\ProgramData', 'adoremix'));
|
|
47
|
+
} else {
|
|
48
|
+
candidates.push('/opt/adoremix');
|
|
49
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
50
|
+
if (xdg) candidates.push(path.join(xdg, 'adoremix'));
|
|
51
|
+
candidates.push(path.join(os.homedir(), '.local', 'share', 'adoremix'));
|
|
52
|
+
}
|
|
53
|
+
for (const c of candidates) {
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(path.join(c, '.adoremix-installed'))) return c;
|
|
56
|
+
} catch (e) { /* 无权限读取则跳过 */ }
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
40
61
|
function defaultWorkdir() {
|
|
62
|
+
const detected = detectInstalledWorkdir();
|
|
63
|
+
if (detected) return detected;
|
|
41
64
|
if (process.platform === 'win32') {
|
|
42
65
|
const base = process.env.PROGRAMDATA || 'C:\\ProgramData';
|
|
43
66
|
return path.join(base, 'adoremix');
|
package/src/runner/spawn.js
CHANGED
|
@@ -29,6 +29,17 @@ function ensureExec(binPath) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// 启动前检查工作目录关键文件:config.ini / .Adore.db 缺失会直接导致应用读不到配置/数据库
|
|
33
|
+
function warnMissingWorkdirFiles(workdir) {
|
|
34
|
+
const missing = [];
|
|
35
|
+
if (!fs.existsSync(path.join(workdir, 'config.ini'))) missing.push('config.ini');
|
|
36
|
+
if (!fs.existsSync(path.join(workdir, '.Adore.db'))) missing.push('.Adore.db');
|
|
37
|
+
if (missing.length) {
|
|
38
|
+
logger.warn(`⚠ 工作目录 ${workdir} 缺少 ${missing.join('、')},应用可能无法正确启动/读库。`);
|
|
39
|
+
logger.warn(` 请运行:adoremix install --force(刷新资源/数据库,保留 config.ini)`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
function startForeground(opts) {
|
|
33
44
|
const native = opts.native;
|
|
34
45
|
const workdir = opts.workdir;
|
|
@@ -44,6 +55,7 @@ function startForeground(opts) {
|
|
|
44
55
|
throw new Error(`原生二进制不存在 ${bin}`);
|
|
45
56
|
}
|
|
46
57
|
ensureExec(bin);
|
|
58
|
+
warnMissingWorkdirFiles(workdir);
|
|
47
59
|
|
|
48
60
|
const args = [path.basename(configPath)];
|
|
49
61
|
logger.info(`spawn ${native.binName} ${args.join(' ')} (cwd=${workdir})`);
|
|
@@ -91,6 +103,7 @@ function startDaemon(opts) {
|
|
|
91
103
|
throw new Error(`原生二进制不存在 ${bin}`);
|
|
92
104
|
}
|
|
93
105
|
ensureExec(bin);
|
|
106
|
+
warnMissingWorkdirFiles(workdir);
|
|
94
107
|
|
|
95
108
|
const running = pidMgr.readPid(wp.pidfile);
|
|
96
109
|
if (running && pidMgr.isRunning(running)) {
|