claude-code-watch 0.0.3 → 0.0.4
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 +1 -1
- package/src/server/server.js +26 -31
package/package.json
CHANGED
package/src/server/server.js
CHANGED
|
@@ -329,7 +329,7 @@ class DashboardServer {
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
start(options = {}) {
|
|
332
|
+
async start(options = {}) {
|
|
333
333
|
const skipHistory = options.skipHistory || false;
|
|
334
334
|
const pollMs = options.pollMs || 500;
|
|
335
335
|
const activeWindow = options.activeWindow || 5 * 60 * 1000;
|
|
@@ -342,34 +342,11 @@ class DashboardServer {
|
|
|
342
342
|
maxSessions,
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
console.log(` Local: ${url}`);
|
|
351
|
-
console.log(` Network: http://${this.host}:${this.port}`);
|
|
352
|
-
console.log(` Quit: Ctrl+C\n`);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
this.server.on('error', async (err) => {
|
|
356
|
-
if (err.code === 'EADDRINUSE') {
|
|
357
|
-
console.log(`Port ${this.port} is in use, killing existing process...`);
|
|
358
|
-
const killed = await this.killExistingPort(this.port);
|
|
359
|
-
if (killed) {
|
|
360
|
-
console.log(`Existing process killed, restarting...`);
|
|
361
|
-
this.server.close();
|
|
362
|
-
doListen();
|
|
363
|
-
} else {
|
|
364
|
-
console.error(`Failed to free port ${this.port}, exiting.`);
|
|
365
|
-
process.exit(1);
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
console.error(`Server error: ${err.message}`);
|
|
369
|
-
process.exit(1);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
};
|
|
345
|
+
// Proactively kill any process occupying the port before starting
|
|
346
|
+
const killed = await this.killExistingPort(this.port);
|
|
347
|
+
if (killed) {
|
|
348
|
+
console.log(`Previous instance on port ${this.port} killed, restarting...`);
|
|
349
|
+
}
|
|
373
350
|
|
|
374
351
|
this.server = http.createServer((req, res) => {
|
|
375
352
|
this.handleHTTP(req, res).catch(() => {
|
|
@@ -383,6 +360,17 @@ class DashboardServer {
|
|
|
383
360
|
this.wss = new WebSocketServer({ server: this.server });
|
|
384
361
|
this.wss.on('connection', (ws) => this.onWsConnection(ws));
|
|
385
362
|
|
|
363
|
+
// Register error handler once (not inside doListen to avoid accumulation)
|
|
364
|
+
this.server.on('error', (err) => {
|
|
365
|
+
if (err.code === 'EADDRINUSE') {
|
|
366
|
+
console.error(`Port ${this.port} is still in use after attempting to free it. Exiting.`);
|
|
367
|
+
process.exit(1);
|
|
368
|
+
} else {
|
|
369
|
+
console.error(`Server error: ${err.message}`);
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
386
374
|
const w = this.setupWatcher(watcherOpts);
|
|
387
375
|
|
|
388
376
|
w.init().then(() => {
|
|
@@ -404,7 +392,14 @@ class DashboardServer {
|
|
|
404
392
|
process.exit(1);
|
|
405
393
|
});
|
|
406
394
|
|
|
407
|
-
|
|
395
|
+
this.server.listen(this.port, this.host, () => {
|
|
396
|
+
const url = `http://localhost:${this.port}`;
|
|
397
|
+
console.log(`\n claude-watch web server`);
|
|
398
|
+
console.log(` ───────────────────────────`);
|
|
399
|
+
console.log(` Local: ${url}`);
|
|
400
|
+
console.log(` Network: http://${this.host}:${this.port}`);
|
|
401
|
+
console.log(` Quit: Ctrl+C\n`);
|
|
402
|
+
});
|
|
408
403
|
|
|
409
404
|
return { server: this.server, watcher: w };
|
|
410
405
|
}
|
|
@@ -417,7 +412,7 @@ class DashboardServer {
|
|
|
417
412
|
}
|
|
418
413
|
}
|
|
419
414
|
|
|
420
|
-
function startServer(options = {}) {
|
|
415
|
+
async function startServer(options = {}) {
|
|
421
416
|
const ds = new DashboardServer(options);
|
|
422
417
|
return ds.start(options);
|
|
423
418
|
}
|