troxy-cli 1.7.0 → 1.7.2
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/troxy.js +31 -10
- package/package.json +1 -1
- package/src/daemon.js +1 -1
package/bin/troxy.js
CHANGED
|
@@ -365,21 +365,42 @@ switch (command) {
|
|
|
365
365
|
// ── Restart MCP service ───────────────────────────────────────
|
|
366
366
|
case 'restart': {
|
|
367
367
|
const { execSync: _execSyncRestart } = await import('child_process');
|
|
368
|
-
const
|
|
369
|
-
|
|
368
|
+
const fsR = await import('fs');
|
|
369
|
+
const osR = (await import('os')).default;
|
|
370
|
+
console.log('\n Restarting Troxy service...');
|
|
370
371
|
try {
|
|
371
|
-
if (
|
|
372
|
+
if (osR.platform() === 'linux') {
|
|
373
|
+
// Migrate service file from old "troxy mcp" to "troxy daemon" if needed
|
|
374
|
+
const svcPath = '/etc/systemd/system/troxy-mcp.service';
|
|
375
|
+
if (fsR.existsSync(svcPath)) {
|
|
376
|
+
const svc = fsR.readFileSync(svcPath, 'utf8');
|
|
377
|
+
if (svc.includes('ExecStart=') && svc.includes(' mcp') && !svc.includes(' daemon')) {
|
|
378
|
+
const fixed = svc.replace(/(ExecStart=\S+) mcp/, '$1 daemon');
|
|
379
|
+
fsR.writeFileSync('/tmp/troxy-mcp.service', fixed);
|
|
380
|
+
_execSyncRestart('sudo mv /tmp/troxy-mcp.service /etc/systemd/system/troxy-mcp.service');
|
|
381
|
+
_execSyncRestart('sudo systemctl daemon-reload');
|
|
382
|
+
process.stdout.write(' Migrated service to daemon mode ✓\n');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
372
385
|
_execSyncRestart('sudo systemctl restart troxy-mcp', { stdio: 'inherit' });
|
|
373
|
-
} else if (
|
|
374
|
-
const
|
|
375
|
-
|
|
386
|
+
} else if (osR.platform() === 'darwin') {
|
|
387
|
+
const plistPath = osR.homedir() + '/Library/LaunchAgents/ai.troxy.mcp.plist';
|
|
388
|
+
if (fsR.existsSync(plistPath)) {
|
|
389
|
+
const plist = fsR.readFileSync(plistPath, 'utf8');
|
|
390
|
+
if (plist.includes('<string>mcp</string>')) {
|
|
391
|
+
const fixed = plist.replace('<string>mcp</string>', '<string>daemon</string>');
|
|
392
|
+
fsR.writeFileSync(plistPath, fixed);
|
|
393
|
+
process.stdout.write(' Migrated service to daemon mode ✓\n');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
_execSyncRestart(`launchctl unload ${plistPath} 2>/dev/null; launchctl load ${plistPath}`, { shell: true, stdio: 'inherit' });
|
|
376
397
|
} else {
|
|
377
|
-
console.error('\n Restart is only supported on Linux and macOS.\n
|
|
398
|
+
console.error('\n Restart is only supported on Linux and macOS.\n');
|
|
378
399
|
process.exit(1);
|
|
379
400
|
}
|
|
380
|
-
console.log('
|
|
381
|
-
} catch {
|
|
382
|
-
console.error('\n Could not restart service. Try manually:\n Linux: sudo systemctl restart troxy-mcp\n macOS: launchctl unload/load ~/Library/LaunchAgents/
|
|
401
|
+
console.log(' Service restarted ✓\n');
|
|
402
|
+
} catch (e) {
|
|
403
|
+
console.error('\n Could not restart service. Try manually:\n Linux: sudo systemctl restart troxy-mcp\n macOS: launchctl unload/load ~/Library/LaunchAgents/ai.troxy.mcp.plist\n');
|
|
383
404
|
process.exit(1);
|
|
384
405
|
}
|
|
385
406
|
break;
|
package/package.json
CHANGED