@c4a/server-cli 0.4.10-beta.1 → 0.4.10-beta.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/index.js +10 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -211880,9 +211880,14 @@ function resolveServerLogPath() {
|
|
|
211880
211880
|
return path13.resolve(process.cwd(), SERVER_LOG_DIR, makeServerLogName());
|
|
211881
211881
|
}
|
|
211882
211882
|
function resolveHealthUrl(config2) {
|
|
211883
|
-
|
|
211884
|
-
|
|
211885
|
-
|
|
211883
|
+
let host = config2.server.host;
|
|
211884
|
+
if (host === "0.0.0.0")
|
|
211885
|
+
host = "127.0.0.1";
|
|
211886
|
+
else if (host === "::")
|
|
211887
|
+
host = "::1";
|
|
211888
|
+
const urlHost = host.includes(":") ? `[${host}]` : host;
|
|
211889
|
+
const url2 = `http://${urlHost}:${config2.server.port}/api/v1/health`;
|
|
211890
|
+
return { url: url2, host: urlHost, tcpHost: host };
|
|
211886
211891
|
}
|
|
211887
211892
|
async function ensureLogDirs() {
|
|
211888
211893
|
await mkdir3(path13.resolve(process.cwd(), SERVER_LOG_DIR), { recursive: true });
|
|
@@ -211967,7 +211972,7 @@ async function startServerProcess(config2, deps = {}) {
|
|
|
211967
211972
|
if (existingPid) {
|
|
211968
211973
|
await removePidFile();
|
|
211969
211974
|
}
|
|
211970
|
-
const { host: healthHost } = resolveHealthUrl(config2);
|
|
211975
|
+
const { host: healthHost, tcpHost } = resolveHealthUrl(config2);
|
|
211971
211976
|
const preCheck = await activeDeps.checkHttp(`http://${healthHost}:${config2.server.port}/api/v1/health`, undefined, 500);
|
|
211972
211977
|
if (preCheck.ok && preCheck.status === 200) {
|
|
211973
211978
|
const orphanPid = findPidByPort(config2.server.port);
|
|
@@ -211976,7 +211981,7 @@ async function startServerProcess(config2, deps = {}) {
|
|
|
211976
211981
|
return { pid: orphanPid, port: config2.server.port, host: config2.server.host, running: true };
|
|
211977
211982
|
}
|
|
211978
211983
|
}
|
|
211979
|
-
const tcpCheck = await activeDeps.checkTcp(
|
|
211984
|
+
const tcpCheck = await activeDeps.checkTcp(tcpHost, config2.server.port, 500);
|
|
211980
211985
|
if (tcpCheck.ok) {
|
|
211981
211986
|
throw new Error(`端口已被占用: ${config2.server.host}:${config2.server.port}`);
|
|
211982
211987
|
}
|