@titanpl/cli 26.16.8 ā 26.16.11
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/engine.js +48 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@titanpl/cli",
|
|
3
|
-
"version": "26.16.
|
|
3
|
+
"version": "26.16.11",
|
|
4
4
|
"description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"titanpl",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"titan": "./index.js"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@titanpl/engine-win32-x64": "26.16.
|
|
23
|
-
"@titanpl/engine-linux-x64": "26.16.
|
|
24
|
-
"@titanpl/engine-darwin-arm64": "26.16.
|
|
22
|
+
"@titanpl/engine-win32-x64": "26.16.11",
|
|
23
|
+
"@titanpl/engine-linux-x64": "26.16.11",
|
|
24
|
+
"@titanpl/engine-darwin-arm64": "26.16.11"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@titanpl/packet": "26.16.
|
|
27
|
+
"@titanpl/packet": "26.16.11",
|
|
28
28
|
"prompts": "^2.4.2",
|
|
29
29
|
"commander": "^11.0.0",
|
|
30
30
|
"chalk": "^4.1.2"
|
package/src/engine.js
CHANGED
|
@@ -58,7 +58,7 @@ export function startEngine(watchMode = false) {
|
|
|
58
58
|
console.log(`š Starting Titan Engine...`);
|
|
59
59
|
|
|
60
60
|
const engineProcess = spawn(binaryPath, args, {
|
|
61
|
-
stdio: 'inherit',
|
|
61
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
62
62
|
env: {
|
|
63
63
|
...process.env,
|
|
64
64
|
TITAN_ENV: watchMode ? 'development' : 'production',
|
|
@@ -66,9 +66,54 @@ export function startEngine(watchMode = false) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
let stderrBuffer = "";
|
|
70
|
+
|
|
71
|
+
engineProcess.stdout.pipe(process.stdout);
|
|
72
|
+
engineProcess.stderr.on('data', (data) => {
|
|
73
|
+
const chunk = data.toString();
|
|
74
|
+
stderrBuffer += chunk;
|
|
75
|
+
process.stderr.write(data);
|
|
76
|
+
});
|
|
77
|
+
|
|
69
78
|
engineProcess.on('close', (code) => {
|
|
70
|
-
if (code !== 0 && code !== null
|
|
71
|
-
|
|
79
|
+
if (code !== 0 && code !== null) {
|
|
80
|
+
// Check for port binding errors
|
|
81
|
+
const isPortError = stderrBuffer.includes("Address already in use") ||
|
|
82
|
+
stderrBuffer.includes("address in use") ||
|
|
83
|
+
stderrBuffer.includes("os error 10048") || // Windows
|
|
84
|
+
stderrBuffer.includes("EADDRINUSE") ||
|
|
85
|
+
stderrBuffer.includes("AddrInUse");
|
|
86
|
+
|
|
87
|
+
if (isPortError) {
|
|
88
|
+
// Try to read intended port
|
|
89
|
+
let port = 5100;
|
|
90
|
+
try {
|
|
91
|
+
const routesPath = path.join(process.cwd(), "dist", "routes.json");
|
|
92
|
+
if (fs.existsSync(routesPath)) {
|
|
93
|
+
const routesConfig = JSON.parse(fs.readFileSync(routesPath, "utf8"));
|
|
94
|
+
if (routesConfig && routesConfig.__config && routesConfig.__config.port) {
|
|
95
|
+
port = routesConfig.__config.port;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (e) { }
|
|
99
|
+
|
|
100
|
+
const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
|
|
101
|
+
const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
|
|
102
|
+
const red = (t) => `\x1b[31m${t}\x1b[0m`;
|
|
103
|
+
|
|
104
|
+
console.log("");
|
|
105
|
+
console.log(red("⣠Your application cannot enter this orbit"));
|
|
106
|
+
console.log(red(`ā³ Another application is already bound to port ${port}.`));
|
|
107
|
+
console.log("");
|
|
108
|
+
|
|
109
|
+
console.log(yellow("Recommended Actions:"));
|
|
110
|
+
console.log(yellow(" 1.") + " Release the occupied orbit (stop the other service).");
|
|
111
|
+
console.log(yellow(" 2.") + " Assign your application to a new orbit in " + cyan("app/app.js"));
|
|
112
|
+
console.log(yellow(" Example: ") + cyan(`t.start(${port + 1}, "Titan Running!")`));
|
|
113
|
+
console.log("");
|
|
114
|
+
} else {
|
|
115
|
+
console.error(`\nā [Titan Engine died with exit code ${code}]`);
|
|
116
|
+
}
|
|
72
117
|
}
|
|
73
118
|
});
|
|
74
119
|
|