@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.
Files changed (2) hide show
  1. package/index.js +34 -15
  2. 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
- // ---- FIX: Proper kill for Windows ----
112
- if (rustProcess) {
113
- console.log(yellow("[Titan] Killing old Rust server..."));
114
-
115
- if (process.platform === "win32") {
116
- spawn("taskkill", ["/PID", rustProcess.pid, "/T", "/F"], {
117
- stdio: "inherit",
118
- shell: true
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.kill();
132
+ rustProcess = launchRust(resolve);
122
133
  }
123
- }
134
+ });
135
+ }
124
136
 
125
- // ---- START NEW PROCESS ----
126
- rustProcess = spawn("cargo", ["run"], {
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
- rustProcess.on("close", (code) => {
133
- console.log(red(`[Titan] Rust server exited: ${code}`));
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" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezetgalaxy/titan",
3
- "version": "25.12.0",
3
+ "version": "25.12.1",
4
4
  "description": "JavaScript backend framework that compiles your JS into a Rust + Axum server.",
5
5
  "license": "ISC",
6
6
  "author": "ezetgalaxy",