50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import * as plugins from '../../../plugins.js';
|
|
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
|
import type { CliArguments } from '../../types.js';
|
|
import { registerIpcCommand } from '../../registration/index.js';
|
|
import { formatMemory } from '../../helpers/memory.js';
|
|
|
|
export function registerDescribeCommand(smartcli: plugins.smartcli.Smartcli) {
|
|
registerIpcCommand(
|
|
smartcli,
|
|
'describe',
|
|
async (argvArg: CliArguments) => {
|
|
const id = argvArg._[1];
|
|
if (!id) {
|
|
console.error('Error: Please provide a process ID');
|
|
console.log('Usage: tspm describe <id>');
|
|
return;
|
|
}
|
|
|
|
const response = await tspmIpcClient.request('describe', { id });
|
|
|
|
console.log(`Process Details: ${id}`);
|
|
console.log('─'.repeat(40));
|
|
console.log(`Status: ${response.processInfo.status}`);
|
|
console.log(`PID: ${response.processInfo.pid || 'N/A'}`);
|
|
console.log(`Memory: ${formatMemory(response.processInfo.memory)}`);
|
|
console.log(
|
|
`CPU: ${response.processInfo.cpu ? response.processInfo.cpu.toFixed(1) + '%' : 'N/A'}`,
|
|
);
|
|
console.log(
|
|
`Uptime: ${response.processInfo.uptime ? Math.floor(response.processInfo.uptime / 1000) + 's' : 'N/A'}`,
|
|
);
|
|
console.log(`Restarts: ${response.processInfo.restarts}`);
|
|
console.log('\nConfiguration:');
|
|
console.log(`Command: ${response.config.command}`);
|
|
console.log(`Directory: ${response.config.projectDir}`);
|
|
console.log(
|
|
`Memory Limit: ${formatMemory(response.config.memoryLimitBytes)}`,
|
|
);
|
|
console.log(`Auto-restart: ${response.config.autorestart}`);
|
|
if (response.config.watch) {
|
|
console.log(`Watch: enabled`);
|
|
if (response.config.watchPaths) {
|
|
console.log(`Watch Paths: ${response.config.watchPaths.join(', ')}`);
|
|
}
|
|
}
|
|
},
|
|
{ actionLabel: 'describe process' },
|
|
);
|
|
}
|