feat(cli/daemon/processmonitor): Add flexible target resolution and search command; improve restart/backoff and error handling
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import { toProcessId } from '../../../shared/protocol/id.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
||||
@@ -11,9 +10,9 @@ export function registerRestartCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
async (argvArg: CliArguments) => {
|
||||
const arg = argvArg._[1];
|
||||
if (!arg) {
|
||||
console.error('Error: Please provide a process ID or "all"');
|
||||
console.error('Error: Please provide a process target or "all"');
|
||||
console.log('Usage:');
|
||||
console.log(' tspm restart <id>');
|
||||
console.log(' tspm restart <id | id:N | name:LABEL>');
|
||||
console.log(' tspm restart all');
|
||||
return;
|
||||
}
|
||||
@@ -33,12 +32,13 @@ export function registerRestartCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = String(arg);
|
||||
console.log(`Restarting process: ${id}`);
|
||||
const response = await tspmIpcClient.request('restart', { id: toProcessId(id) });
|
||||
const target = String(arg);
|
||||
console.log(`Restarting process: ${target}`);
|
||||
const resolved = await tspmIpcClient.request('resolveTarget', { target });
|
||||
const response = await tspmIpcClient.request('restart', { id: resolved.id });
|
||||
|
||||
console.log(`✓ Process restarted successfully`);
|
||||
console.log(` ID: ${response.processId}`);
|
||||
console.log(` ID: ${response.processId}${resolved.name ? ` (name: ${resolved.name})` : ''}`);
|
||||
console.log(` PID: ${response.pid || 'N/A'}`);
|
||||
console.log(` Status: ${response.status}`);
|
||||
},
|
||||
|
Reference in New Issue
Block a user