@ezetgalaxy/titan 26.6.8 → 26.7.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezetgalaxy/titan",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.7.1",
|
|
4
4
|
"description": "Titan Planet is a JavaScript-first backend framework that embeds JS actions into a Rust + Axum server and ships as a single native binary. Routes are compiled to static metadata; only actions run in the embedded JS runtime. No Node.js. No event loop in production.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "ezetgalaxy",
|
package/templates/package.json
CHANGED
package/templates/titan/dev.js
CHANGED
|
@@ -10,10 +10,12 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
|
|
12
12
|
let serverProcess = null;
|
|
13
|
+
let isKilling = false;
|
|
13
14
|
|
|
14
15
|
async function killServer() {
|
|
15
16
|
if (!serverProcess) return;
|
|
16
17
|
|
|
18
|
+
isKilling = true;
|
|
17
19
|
const pid = serverProcess.pid;
|
|
18
20
|
const killPromise = new Promise((resolve) => {
|
|
19
21
|
if (serverProcess.exitCode !== null) return resolve();
|
|
@@ -34,25 +36,47 @@ async function killServer() {
|
|
|
34
36
|
await killPromise;
|
|
35
37
|
} catch (e) { }
|
|
36
38
|
serverProcess = null;
|
|
39
|
+
isKilling = false;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
async function startRustServer() {
|
|
42
|
+
async function startRustServer(retryCount = 0) {
|
|
43
|
+
// If we are retrying, give it more time (2s), otherwise standard 1s (increased from 500ms)
|
|
44
|
+
const waitTime = retryCount > 0 ? 2000 : 1000;
|
|
45
|
+
|
|
46
|
+
// Ensure any previous instance is killed
|
|
40
47
|
await killServer();
|
|
41
48
|
|
|
49
|
+
// Give the OS a moment to release file locks on the binary
|
|
50
|
+
await new Promise(r => setTimeout(r, waitTime));
|
|
51
|
+
|
|
42
52
|
const serverPath = path.join(process.cwd(), "server");
|
|
53
|
+
const startTime = Date.now();
|
|
54
|
+
|
|
55
|
+
if (retryCount > 0) {
|
|
56
|
+
console.log(`\x1b[33m[Titan] Retrying Rust server (Attempt ${retryCount})...\x1b[0m`);
|
|
57
|
+
}
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
// Windows often has file locking issues during concurrent linking/metadata generation
|
|
60
|
+
// We force 1 job and disable incremental compilation to be safe.
|
|
61
|
+
serverProcess = spawn("cargo", ["run", "--jobs", "1"], {
|
|
45
62
|
cwd: serverPath,
|
|
46
63
|
stdio: "inherit",
|
|
47
|
-
shell: true
|
|
64
|
+
shell: true,
|
|
65
|
+
env: { ...process.env, CARGO_INCREMENTAL: "0" }
|
|
48
66
|
});
|
|
49
67
|
|
|
50
|
-
serverProcess.on("close", (code) => {
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
// We just log it.
|
|
54
|
-
}
|
|
68
|
+
serverProcess.on("close", async (code) => {
|
|
69
|
+
if (isKilling) return;
|
|
70
|
+
|
|
55
71
|
console.log(`[Titan] Rust server exited: ${code}`);
|
|
72
|
+
|
|
73
|
+
// If exited with error and it was a short run (< 10s), likely a start-up error/lock
|
|
74
|
+
// Retry up to 3 times
|
|
75
|
+
const runTime = Date.now() - startTime;
|
|
76
|
+
if (code !== 0 && code !== null && runTime < 10000 && retryCount < 3) {
|
|
77
|
+
console.log(`\x1b[31m[Titan] Server crash detected (possibly file lock). Retrying automatically...\x1b[0m`);
|
|
78
|
+
await startRustServer(retryCount + 1);
|
|
79
|
+
}
|
|
56
80
|
});
|
|
57
81
|
}
|
|
58
82
|
|
|
@@ -103,8 +127,18 @@ async function startDev() {
|
|
|
103
127
|
console.log("\x1b[31m[Titan] Build failed -- waiting for changes...\x1b[0m");
|
|
104
128
|
}
|
|
105
129
|
|
|
106
|
-
},
|
|
130
|
+
}, 500);
|
|
107
131
|
});
|
|
108
132
|
}
|
|
109
133
|
|
|
134
|
+
// Handle graceful exit to release file locks
|
|
135
|
+
async function handleExit() {
|
|
136
|
+
console.log("\n[Titan] Stopping server...");
|
|
137
|
+
await killServer();
|
|
138
|
+
process.exit(0);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
process.on("SIGINT", handleExit);
|
|
142
|
+
process.on("SIGTERM", handleExit);
|
|
143
|
+
|
|
110
144
|
startDev();
|
package/titanpl-sdk/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "titanpl-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Development SDK for Titan Planet. Provides TypeScript type definitions for the global 't' runtime object and a 'lite' test-harness runtime for building and verifying extensions.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,9 @@ async function killServer() {
|
|
|
39
39
|
async function startRustServer() {
|
|
40
40
|
await killServer();
|
|
41
41
|
|
|
42
|
+
// Give the OS a moment to release file locks on the binary
|
|
43
|
+
await new Promise(r => setTimeout(r, 500));
|
|
44
|
+
|
|
42
45
|
const serverPath = path.join(process.cwd(), "server");
|
|
43
46
|
|
|
44
47
|
serverProcess = spawn("cargo", ["run"], {
|