badmfck-api-server 4.1.53 → 4.1.58
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/dist/apiServer/APIService.d.ts +3 -4
- package/dist/apiServer/APIService.js +19 -9
- package/dist/apiServer/BaseEndpoint.d.ts +2 -2
- package/dist/apiServer/LocalRequest.d.ts +1 -1
- package/dist/apiServer/LogService.js +17 -7
- package/dist/apiServer/MonitorService.d.ts +0 -1
- package/dist/apiServer/MonitorService.js +17 -7
- package/dist/apiServer/MysqlService.d.ts +1 -2
- package/dist/apiServer/MysqlService.js +17 -7
- package/dist/apiServer/TimeframeService.js +17 -7
- package/dist/apiServer/db/MysqlAdapter.d.ts +1 -1
- package/dist/apiServer/db/MysqlAdapter.js +37 -12
- package/dist/apiServer/deployment/Activate.js +1 -2
- package/dist/apiServer/deployment/ConfigService.d.ts +26 -26
- package/dist/apiServer/deployment/ConfigService.js +17 -7
- package/dist/apiServer/deployment/Deploy.js +1 -2
- package/dist/apiServer/deployment/DeployerService.d.ts +10 -9
- package/dist/apiServer/deployment/DeployerService.js +18 -1
- package/dist/apiServer/deployment/cli.js +37 -14
- package/dist/apiServer/deployment/resolveConfig.js +2 -3
- package/dist/apiServer/documentation/index.html +25 -25
- package/dist/apiServer/external/ExternalService.js +17 -7
- package/dist/apiServer/external/MicroserviceClient.js +17 -7
- package/dist/apiServer/external/MicroserviceHost.js +17 -7
- package/dist/apiServer/external/MicroserviceHostController.js +17 -7
- package/dist/apiServer/helper/JSONStableStringify.js +1 -2
- package/dist/apiServer/helper/YYYYMMDDHH.js +2 -3
- package/dist/apiServer/helper/ZipUtils.d.ts +0 -2
- package/dist/apiServer/monitor/Monitor.d.ts +9 -1
- package/dist/apiServer/monitor/Monitor.js +28 -2
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +61 -1
- package/dist/apiServer/monitor/ProcessMonitor.js +160 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +7 -8
- package/dist/apiServer/monitor/SystemInfo.js +1 -2
- package/dist/apiServer/monitor/index.html +53 -53
- package/dist/apiServer/structures/Interfaces.d.ts +0 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -1
- package/package.json +1 -1
|
@@ -496,9 +496,12 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
496
496
|
return new Promise((resolve) => {
|
|
497
497
|
try {
|
|
498
498
|
(0, child_process_1.execFileSync)("pm2", ["--version"]);
|
|
499
|
-
const
|
|
499
|
+
const rawExtra = Array.isArray(pm2Attrs)
|
|
500
500
|
? pm2Attrs.filter(s => typeof s === "string" && s.length > 0)
|
|
501
501
|
: [];
|
|
502
|
+
const extra = rawExtra.filter(a => !/^--no-autorestart(=.*)?$/.test(a));
|
|
503
|
+
if (extra.length !== rawExtra.length)
|
|
504
|
+
(0, LogService_1.logWarn)(`Ignored "--no-autorestart" in pm2 attributes for "${found.name}" — autorestart is force-kept ON so the slot self-recovers.`);
|
|
502
505
|
const ecoJs = path_1.default.resolve(found.destination, "ecosystem.config.js");
|
|
503
506
|
const ecoCjs = path_1.default.resolve(found.destination, "ecosystem.config.cjs");
|
|
504
507
|
const ecosystem = fs_1.default.existsSync(ecoJs) ? ecoJs
|
|
@@ -506,6 +509,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
506
509
|
: null;
|
|
507
510
|
if (ecosystem) {
|
|
508
511
|
(0, child_process_1.execFileSync)("pm2", ["startOrReload", ecosystem, "--update-env", ...extra]);
|
|
512
|
+
this._verifyAutorestart(found.name);
|
|
509
513
|
resolve(null);
|
|
510
514
|
return;
|
|
511
515
|
}
|
|
@@ -530,6 +534,7 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
530
534
|
catch { }
|
|
531
535
|
}
|
|
532
536
|
(0, child_process_1.execFileSync)("pm2", ["start", found.destination + main, "--name", found.name, ...extra]);
|
|
537
|
+
this._verifyAutorestart(found.name);
|
|
533
538
|
resolve(null);
|
|
534
539
|
}
|
|
535
540
|
catch (e) {
|
|
@@ -537,6 +542,18 @@ class DeployerService extends BaseService_1.BaseService {
|
|
|
537
542
|
}
|
|
538
543
|
});
|
|
539
544
|
}
|
|
545
|
+
_verifyAutorestart(name) {
|
|
546
|
+
try {
|
|
547
|
+
const list = JSON.parse((0, child_process_1.execFileSync)("pm2", ["jlist"]).toString());
|
|
548
|
+
const proc = Array.isArray(list) ? list.find((p) => p?.name === name) : null;
|
|
549
|
+
if (proc?.pm2_env && proc.pm2_env.autorestart === false) {
|
|
550
|
+
(0, LogService_1.logWarn)(`pm2 autorestart is DISABLED for "${name}" — the slot will NOT respawn after a restart/exit. Check the project's ecosystem.config (autorestart:false).`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
catch (e) {
|
|
554
|
+
(0, LogService_1.logWarn)(`Could not verify pm2 autorestart for "${name}": ${e?.message ?? e}`);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
540
557
|
static SKIP_DIRS = new Set(["node_modules", ".git", "__tmp"]);
|
|
541
558
|
static TEMPLATE_EXTENSIONS = [".js", ".ts", ".json", ".env"];
|
|
542
559
|
async applyConfig(dir, config) {
|
|
@@ -5,27 +5,50 @@ const Deploy_1 = require("./Deploy");
|
|
|
5
5
|
const Activate_1 = require("./Activate");
|
|
6
6
|
function usage() {
|
|
7
7
|
console.error("Usage:");
|
|
8
|
-
console.error(" badmfck deploy — build + upload the current project");
|
|
9
|
-
console.error(" badmfck activate [blue|green] — switch blue-green slot (omit for lastDeployed)");
|
|
8
|
+
console.error(" badmfck deploy [config.json] — build + upload the current project");
|
|
9
|
+
console.error(" badmfck activate [config.json] [blue|green] — switch blue-green slot (omit slot for lastDeployed)");
|
|
10
|
+
console.error("");
|
|
11
|
+
console.error("Config path is optional (auto-discovers deploy/ folder → deploy.json when omitted).");
|
|
12
|
+
console.error("Via npm, prefix args with -- e.g. npm run deploy -- deploy/custom.json");
|
|
10
13
|
process.exit(1);
|
|
11
14
|
}
|
|
15
|
+
function parseArgs(args) {
|
|
16
|
+
let scheme;
|
|
17
|
+
let config;
|
|
18
|
+
for (const a of args) {
|
|
19
|
+
if (a === "blue" || a === "green") {
|
|
20
|
+
if (scheme) {
|
|
21
|
+
console.error(`Slot specified twice ("${scheme}" and "${a}").`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
scheme = a;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (config) {
|
|
28
|
+
console.error(`Config path specified twice ("${config}" and "${a}").`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
config = a;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { scheme, config };
|
|
35
|
+
}
|
|
12
36
|
async function main() {
|
|
13
37
|
const command = process.argv[2];
|
|
14
|
-
const
|
|
38
|
+
const rest = process.argv.slice(3);
|
|
15
39
|
switch (command) {
|
|
16
|
-
case "deploy":
|
|
17
|
-
|
|
40
|
+
case "deploy": {
|
|
41
|
+
const { scheme, config } = parseArgs(rest);
|
|
42
|
+
if (scheme) {
|
|
43
|
+
console.error(`"deploy" does not take a slot argument ("${scheme}").`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
await (0, Deploy_1.Deploy)(config);
|
|
18
47
|
break;
|
|
48
|
+
}
|
|
19
49
|
case "activate": {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (arg !== "blue" && arg !== "green") {
|
|
23
|
-
console.error(`Invalid slot "${arg}" — expected "blue" or "green".`);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
scheme = arg;
|
|
27
|
-
}
|
|
28
|
-
await (0, Activate_1.Activate)(undefined, scheme);
|
|
50
|
+
const { scheme, config } = parseArgs(rest);
|
|
51
|
+
await (0, Activate_1.Activate)(config, scheme);
|
|
29
52
|
break;
|
|
30
53
|
}
|
|
31
54
|
default:
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.validateConfig = validateConfig;
|
|
7
|
+
exports.resolveConfig = resolveConfig;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const promises_1 = require("readline/promises");
|
|
@@ -21,7 +22,6 @@ function validateConfig(cfg) {
|
|
|
21
22
|
return "switch_host must be a string";
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
|
-
exports.validateConfig = validateConfig;
|
|
25
25
|
async function selectConfig(configs) {
|
|
26
26
|
if (configs.length === 0) {
|
|
27
27
|
throw new Error("No valid deploy configs found");
|
|
@@ -102,4 +102,3 @@ async function resolveConfig(opt) {
|
|
|
102
102
|
}
|
|
103
103
|
return opt;
|
|
104
104
|
}
|
|
105
|
-
exports.resolveConfig = resolveConfig;
|