BREAKING CHANGE(daemon): Refactor daemon and service management: remove IPC auto-spawn, add TspmServiceManager, tighten IPC/client/CLI behavior and tests

This commit is contained in:
2025-08-28 15:52:29 +00:00
parent 8e3cfb624b
commit e73f4acd63
38 changed files with 810 additions and 580 deletions

View File

@@ -9,7 +9,7 @@ import { formatMemory } from '../helpers/memory.js';
export function registerDefaultCommand(smartcli: plugins.smartcli.Smartcli) {
const cliLogger = new Logger('CLI');
const tspmProjectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
smartcli.standardCommand().subscribe({
next: async (argvArg: CliArguments) => {
console.log(
@@ -17,7 +17,9 @@ export function registerDefaultCommand(smartcli: plugins.smartcli.Smartcli) {
);
console.log('Usage: tspm [command] [options]');
console.log('\nService Management:');
console.log(' enable Enable TSPM as system service (systemd)');
console.log(
' enable Enable TSPM as system service (systemd)',
);
console.log(' disable Disable TSPM system service');
console.log('\nProcess Commands:');
console.log(' start <script> Start a process');
@@ -31,7 +33,9 @@ export function registerDefaultCommand(smartcli: plugins.smartcli.Smartcli) {
console.log(' stop-all Stop all processes');
console.log(' restart-all Restart all processes');
console.log('\nDaemon Commands:');
console.log(' daemon start Start daemon manually (current session)');
console.log(
' daemon start Start daemon manually (current session)',
);
console.log(' daemon stop Stop the daemon');
console.log(' daemon status Show daemon status');
console.log(
@@ -78,14 +82,16 @@ export function registerDefaultCommand(smartcli: plugins.smartcli.Smartcli) {
'└─────────┴─────────────┴───────────┴───────────┴──────────┘',
);
}
// Disconnect from daemon after getting list
await tspmIpcClient.disconnect();
} catch (error) {
console.error('Error: TSPM daemon is not running.');
console.log('\nTo start the daemon, run one of:');
console.log(' tspm daemon start - Start for this session only');
console.log(' tspm enable - Enable as system service (recommended)');
console.log(
' tspm enable - Enable as system service (recommended)',
);
}
},
error: (err) => {
@@ -93,4 +99,4 @@ export function registerDefaultCommand(smartcli: plugins.smartcli.Smartcli) {
},
complete: () => {},
});
}
}