tycono 0.1.96-beta.51 → 0.1.96-beta.53
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/bin/tycono.ts +16 -48
- package/package.json +1 -1
package/bin/tycono.ts
CHANGED
|
@@ -221,65 +221,33 @@ async function startServerForTui(): Promise<void> {
|
|
|
221
221
|
const origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
222
222
|
const origLog = (...args: unknown[]) => origStdoutWrite(args.join(' ') + '\n');
|
|
223
223
|
|
|
224
|
-
//
|
|
225
|
-
// This
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
env: {
|
|
232
|
-
...process.env,
|
|
233
|
-
PORT: String(port),
|
|
234
|
-
COMPANY_ROOT: process.env.COMPANY_ROOT,
|
|
235
|
-
},
|
|
236
|
-
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
237
|
-
});
|
|
224
|
+
// Redirect console methods to log file BEFORE importing server code
|
|
225
|
+
// This is the ONLY output suppression — NO stdout.write hijacking
|
|
226
|
+
// Ink needs full control of stdout.write, any interception breaks rendering
|
|
227
|
+
console.log = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
228
|
+
console.error = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
229
|
+
console.warn = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
230
|
+
console.info = (...a: unknown[]) => { logStream.write(a.join(' ') + '\n'); };
|
|
238
231
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
child.stderr?.on('data', (data: Buffer) => { logStream.write(data); });
|
|
242
|
-
|
|
243
|
-
// Wait for server to be ready (poll health endpoint)
|
|
244
|
-
const waitForServer = async () => {
|
|
245
|
-
const http = await import('node:http');
|
|
246
|
-
for (let i = 0; i < 30; i++) {
|
|
247
|
-
try {
|
|
248
|
-
await new Promise<void>((resolve, reject) => {
|
|
249
|
-
const req = http.get(`http://localhost:${port}/api/health`, (res) => {
|
|
250
|
-
res.resume();
|
|
251
|
-
resolve();
|
|
252
|
-
});
|
|
253
|
-
req.on('error', reject);
|
|
254
|
-
req.setTimeout(1000, () => { req.destroy(); reject(new Error('timeout')); });
|
|
255
|
-
});
|
|
256
|
-
return true;
|
|
257
|
-
} catch {
|
|
258
|
-
await new Promise(r => setTimeout(r, 500));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return false;
|
|
262
|
-
};
|
|
232
|
+
const { createHttpServer } = await import('../src/api/src/create-server.js');
|
|
233
|
+
const server = createHttpServer();
|
|
263
234
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
process.exit(1);
|
|
268
|
-
}
|
|
235
|
+
await new Promise<void>((resolve) => {
|
|
236
|
+
server.listen(port, '0.0.0.0', () => resolve());
|
|
237
|
+
});
|
|
269
238
|
|
|
270
239
|
origLog(` API server started on port ${port}`);
|
|
271
240
|
origLog(` Logs: ${logFile}`);
|
|
272
241
|
|
|
273
|
-
// Graceful shutdown
|
|
242
|
+
// Graceful shutdown
|
|
274
243
|
const shutdown = () => {
|
|
275
|
-
|
|
276
|
-
process.exit(
|
|
244
|
+
server.close(() => process.exit(0));
|
|
245
|
+
setTimeout(() => process.exit(1), 5000);
|
|
277
246
|
};
|
|
278
247
|
process.on('SIGINT', shutdown);
|
|
279
248
|
process.on('SIGTERM', shutdown);
|
|
280
|
-
child.on('exit', () => { process.exit(0); });
|
|
281
249
|
|
|
282
|
-
// Start TUI —
|
|
250
|
+
// Start TUI — stdout.write is NOT intercepted, Ink has full control
|
|
283
251
|
const { startTui } = await import('../src/tui/index.tsx');
|
|
284
252
|
await startTui({ port });
|
|
285
253
|
}
|