@ezetgalaxy/titan 25.12.0 → 25.12.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/index.js +34 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -108,32 +108,51 @@ async function devServer() {
|
|
|
108
108
|
let rustProcess = null;
|
|
109
109
|
|
|
110
110
|
function startRust() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
// if server already running → kill it
|
|
113
|
+
if (rustProcess) {
|
|
114
|
+
console.log("[Titan] Killing old Rust server...");
|
|
115
|
+
|
|
116
|
+
if (process.platform === "win32") {
|
|
117
|
+
const killer = spawn("taskkill", ["/PID", rustProcess.pid, "/T", "/F"], {
|
|
118
|
+
stdio: "ignore",
|
|
119
|
+
shell: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
killer.on("exit", () => {
|
|
123
|
+
rustProcess = launchRust(resolve);
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
rustProcess.kill();
|
|
127
|
+
rustProcess.on("close", () => {
|
|
128
|
+
rustProcess = launchRust(resolve);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
120
131
|
} else {
|
|
121
|
-
rustProcess
|
|
132
|
+
rustProcess = launchRust(resolve);
|
|
122
133
|
}
|
|
123
|
-
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
function launchRust(done) {
|
|
138
|
+
const processHandle = spawn("cargo", ["run"], {
|
|
127
139
|
cwd: path.join(process.cwd(), "server"),
|
|
128
140
|
stdio: "inherit",
|
|
129
141
|
shell: true,
|
|
130
142
|
});
|
|
131
143
|
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
processHandle.on("spawn", () => {
|
|
145
|
+
setTimeout(done, 200); // wait for OS to release port
|
|
134
146
|
});
|
|
147
|
+
|
|
148
|
+
processHandle.on("close", (code) => {
|
|
149
|
+
console.log(`[Titan] Rust server exited: ${code}`);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return processHandle;
|
|
135
153
|
}
|
|
136
154
|
|
|
155
|
+
|
|
137
156
|
function rebuild() {
|
|
138
157
|
console.log(cyan("Titan: Regenerating routes..."));
|
|
139
158
|
execSync("node app/app.js", { stdio: "inherit" });
|