@oxiaom/adoremix 1.0.0 → 1.0.2
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 +5 -5
- package/src/runner/spawn.js +26 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxiaom/adoremix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
|
|
5
5
|
"bin": {
|
|
6
6
|
"adoremix": "./bin/adoremix.js"
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"node": ">=16"
|
|
12
12
|
},
|
|
13
13
|
"optionalDependencies": {
|
|
14
|
-
"@oxiaom/adoremix-win32-x64": "1.0.0",
|
|
15
|
-
"@oxiaom/adoremix-linux-x64": "1.0.0",
|
|
16
|
-
"@oxiaom/adoremix-linux-arm64": "1.0.0",
|
|
17
|
-
"@oxiaom/adoremix-linux-arm": "1.0.0"
|
|
14
|
+
"@oxiaom/adoremix-win32-x64": "^1.0.0",
|
|
15
|
+
"@oxiaom/adoremix-linux-x64": "^1.0.0",
|
|
16
|
+
"@oxiaom/adoremix-linux-arm64": "^1.0.0",
|
|
17
|
+
"@oxiaom/adoremix-linux-arm": "^1.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"commander": "^12.1.0",
|
package/src/runner/spawn.js
CHANGED
|
@@ -13,6 +13,22 @@ function ensureLogFiles(workdirPaths) {
|
|
|
13
13
|
fs.mkdirSync(workdirPaths.logsDir, { recursive: true });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function resolveBin(native, workdir) {
|
|
17
|
+
// 优先用工作目录的二进制(install 时已 chmod 0755)
|
|
18
|
+
// 兜底用 node_modules 子包里的二进制(npm 解包后可能缺 +x 权限)
|
|
19
|
+
const workdirBin = path.join(workdir, native.binName);
|
|
20
|
+
if (fs.existsSync(workdirBin)) return workdirBin;
|
|
21
|
+
return native.bin;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function ensureExec(binPath) {
|
|
25
|
+
try {
|
|
26
|
+
fs.chmodSync(binPath, 0o755);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// 忽略权限错误(可能没权限改)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
function startForeground(opts) {
|
|
17
33
|
const native = opts.native;
|
|
18
34
|
const workdir = opts.workdir;
|
|
@@ -23,13 +39,15 @@ function startForeground(opts) {
|
|
|
23
39
|
if (!fs.existsSync(configPath)) {
|
|
24
40
|
throw new Error(`配置不存在 ${configPath},请先运行 adoremix install`);
|
|
25
41
|
}
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
const bin = resolveBin(native, workdir);
|
|
43
|
+
if (!fs.existsSync(bin)) {
|
|
44
|
+
throw new Error(`原生二进制不存在 ${bin}`);
|
|
28
45
|
}
|
|
46
|
+
ensureExec(bin);
|
|
29
47
|
|
|
30
48
|
const args = [path.basename(configPath)];
|
|
31
49
|
logger.info(`spawn ${native.binName} ${args.join(' ')} (cwd=${workdir})`);
|
|
32
|
-
const child = spawn(
|
|
50
|
+
const child = spawn(bin, args, {
|
|
33
51
|
cwd: workdir,
|
|
34
52
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
35
53
|
windowsHide: false
|
|
@@ -68,9 +86,11 @@ function startDaemon(opts) {
|
|
|
68
86
|
if (!fs.existsSync(configPath)) {
|
|
69
87
|
throw new Error(`配置不存在 ${configPath},请先运行 adoremix install`);
|
|
70
88
|
}
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
const bin = resolveBin(native, workdir);
|
|
90
|
+
if (!fs.existsSync(bin)) {
|
|
91
|
+
throw new Error(`原生二进制不存在 ${bin}`);
|
|
73
92
|
}
|
|
93
|
+
ensureExec(bin);
|
|
74
94
|
|
|
75
95
|
const running = pidMgr.readPid(wp.pidfile);
|
|
76
96
|
if (running && pidMgr.isRunning(running)) {
|
|
@@ -82,7 +102,7 @@ function startDaemon(opts) {
|
|
|
82
102
|
const err = fs.openSync(wp.logfile, 'a');
|
|
83
103
|
const args = [path.basename(configPath)];
|
|
84
104
|
logger.info(`spawn ${native.binName} ${args.join(' ')} (cwd=${workdir}, daemon)`);
|
|
85
|
-
const child = spawn(
|
|
105
|
+
const child = spawn(bin, args, {
|
|
86
106
|
cwd: workdir,
|
|
87
107
|
stdio: ['ignore', out, err],
|
|
88
108
|
detached: true,
|