@nuwax-ai/app-cli 0.2.0
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/bin/cli.js +62 -0
- package/package.json +38 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// @nuwax-ai/app-cli wrapper:定位当前平台的二进制子包并代理执行。
|
|
5
|
+
// 与 rcoder-cli 的 wrapper 差异:app-cli serve 是长驻进程(容器 PID1 语义),
|
|
6
|
+
// 改用 spawn + 信号转发(SIGTERM/SIGINT/SIGHUP)——docker stop 时信号必须
|
|
7
|
+
// 到达二进制才能优雅停服务(级联停 pingap 与各子服务)。
|
|
8
|
+
|
|
9
|
+
const { platform, arch } = process;
|
|
10
|
+
const { spawn } = require("child_process");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
|
|
13
|
+
const platformPackages = {
|
|
14
|
+
"linux-x64": "@nuwax-ai/app-cli-linux-x64",
|
|
15
|
+
"linux-arm64": "@nuwax-ai/app-cli-linux-arm64",
|
|
16
|
+
"darwin-x64": "@nuwax-ai/app-cli-darwin-x64",
|
|
17
|
+
"darwin-arm64": "@nuwax-ai/app-cli-darwin-arm64",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const key = `${platform}-${arch}`;
|
|
21
|
+
const pkgName = platformPackages[key];
|
|
22
|
+
|
|
23
|
+
if (!pkgName) {
|
|
24
|
+
console.error(`error: unsupported platform: ${key}`);
|
|
25
|
+
console.error(`supported platforms: ${Object.keys(platformPackages).join(", ")}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let binPath;
|
|
30
|
+
try {
|
|
31
|
+
const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
|
|
32
|
+
binPath = path.join(pkgDir, "app-cli");
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(`error: platform package ${pkgName} not found.`);
|
|
35
|
+
console.error(`please reinstall: npm install -g @nuwax-ai/app-cli`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
40
|
+
|
|
41
|
+
for (const sig of ["SIGTERM", "SIGINT", "SIGHUP"]) {
|
|
42
|
+
process.on(sig, () => {
|
|
43
|
+
try {
|
|
44
|
+
child.kill(sig);
|
|
45
|
+
} catch {
|
|
46
|
+
// 子进程已退出则忽略
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
child.on("error", (e) => {
|
|
52
|
+
console.error(`error: ${e.message}`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
child.on("exit", (code, signal) => {
|
|
57
|
+
if (signal) {
|
|
58
|
+
// 子进程被信号终止:以同信号自杀,让调用方(shell/容器)看到真实死因。
|
|
59
|
+
process.kill(process.pid, signal);
|
|
60
|
+
}
|
|
61
|
+
process.exit(code === null ? 1 : code);
|
|
62
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuwax-ai/app-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "UserApp workspace runtime orchestrator (service orchestration + pingap routing + admin API; local build tool)",
|
|
5
|
+
"main": "./bin/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"app-cli": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"optionalDependencies": {
|
|
10
|
+
"@nuwax-ai/app-cli-linux-x64": "0.2.0",
|
|
11
|
+
"@nuwax-ai/app-cli-linux-arm64": "0.2.0",
|
|
12
|
+
"@nuwax-ai/app-cli-darwin-x64": "0.2.0",
|
|
13
|
+
"@nuwax-ai/app-cli-darwin-arm64": "0.2.0"
|
|
14
|
+
},
|
|
15
|
+
"os": [
|
|
16
|
+
"linux",
|
|
17
|
+
"darwin"
|
|
18
|
+
],
|
|
19
|
+
"cpu": [
|
|
20
|
+
"x64",
|
|
21
|
+
"arm64"
|
|
22
|
+
],
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"homepage": "https://github.com/nuwax-ai/rcoder",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"userapp",
|
|
27
|
+
"orchestrator",
|
|
28
|
+
"pingap",
|
|
29
|
+
"workspace"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/nuwax-ai/rcoder.git"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|