hedgequantx 2.7.77 → 2.7.79

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": "hedgequantx",
3
- "version": "2.7.77",
3
+ "version": "2.7.79",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -296,12 +296,45 @@ const stop = async () => {
296
296
  try {
297
297
  if (status.pid) {
298
298
  process.kill(status.pid, 'SIGTERM');
299
+ } else {
300
+ // No PID - try to find and kill by port (only cli-proxy-api process)
301
+ const { execSync } = require('child_process');
302
+ try {
303
+ if (process.platform === 'win32') {
304
+ // Windows: find PID by port and kill
305
+ const result = execSync(`netstat -ano | findstr :${DEFAULT_PORT} | findstr LISTENING`, { encoding: 'utf8' });
306
+ const match = result.match(/LISTENING\s+(\d+)/);
307
+ if (match) {
308
+ const pid = parseInt(match[1]);
309
+ if (pid !== process.pid) process.kill(pid, 'SIGTERM');
310
+ }
311
+ } else {
312
+ // Unix: find PID listening on port, filter to only cli-proxy-api
313
+ try {
314
+ const result = execSync(`lsof -ti:${DEFAULT_PORT} -sTCP:LISTEN 2>/dev/null || true`, { encoding: 'utf8' });
315
+ const pids = result.trim().split('\n').filter(p => p && parseInt(p) !== process.pid);
316
+ for (const pidStr of pids) {
317
+ const pid = parseInt(pidStr);
318
+ if (pid && pid !== process.pid) {
319
+ try { process.kill(pid, 'SIGTERM'); } catch (e) { /* ignore */ }
320
+ }
321
+ }
322
+ } catch (e) {
323
+ // Ignore errors
324
+ }
325
+ }
326
+ } catch (e) {
327
+ // Ignore errors - process may already be dead
328
+ }
299
329
  }
300
330
 
301
331
  if (fs.existsSync(PID_FILE)) {
302
332
  fs.unlinkSync(PID_FILE);
303
333
  }
304
334
 
335
+ // Wait for port to be released
336
+ await new Promise(r => setTimeout(r, 1000));
337
+
305
338
  return { success: true, error: null };
306
339
  } catch (error) {
307
340
  return { success: false, error: error.message };