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:
@@ -18,14 +18,14 @@ export class TspmServiceManager {
|
||||
private async getOrCreateService(): Promise<any> {
|
||||
if (!this.service) {
|
||||
const cliPath = plugins.path.join(paths.packageDir, 'cli.js');
|
||||
|
||||
|
||||
// Create service configuration
|
||||
this.service = await this.smartDaemon.addService({
|
||||
name: 'tspm-daemon',
|
||||
description: 'TSPM Process Manager Daemon',
|
||||
command: `${process.execPath} ${cliPath} daemon start-service`,
|
||||
workingDir: process.env.HOME || process.cwd(),
|
||||
version: '1.0.0'
|
||||
version: '1.0.0',
|
||||
});
|
||||
}
|
||||
return this.service;
|
||||
@@ -36,13 +36,13 @@ export class TspmServiceManager {
|
||||
*/
|
||||
public async enableService(): Promise<void> {
|
||||
const service = await this.getOrCreateService();
|
||||
|
||||
|
||||
// Save service configuration
|
||||
await service.save();
|
||||
|
||||
|
||||
// Enable service to start on boot
|
||||
await service.enable();
|
||||
|
||||
|
||||
// Start the service immediately
|
||||
await service.start();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export class TspmServiceManager {
|
||||
*/
|
||||
public async disableService(): Promise<void> {
|
||||
const service = await this.getOrCreateService();
|
||||
|
||||
|
||||
// Stop the service if running
|
||||
try {
|
||||
await service.stop();
|
||||
@@ -60,7 +60,7 @@ export class TspmServiceManager {
|
||||
// Service might not be running
|
||||
console.log('Service was not running');
|
||||
}
|
||||
|
||||
|
||||
// Disable service from starting on boot
|
||||
await service.disable();
|
||||
}
|
||||
@@ -75,20 +75,20 @@ export class TspmServiceManager {
|
||||
}> {
|
||||
try {
|
||||
await this.getOrCreateService();
|
||||
|
||||
|
||||
// Note: SmartDaemon doesn't provide direct status methods,
|
||||
// so we'll need to check via systemctl commands
|
||||
// This is a simplified implementation
|
||||
return {
|
||||
enabled: true, // Would need to check systemctl is-enabled
|
||||
running: true, // Would need to check systemctl is-active
|
||||
status: 'active'
|
||||
status: 'active',
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
enabled: false,
|
||||
running: false,
|
||||
status: 'inactive'
|
||||
status: 'inactive',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -100,4 +100,4 @@ export class TspmServiceManager {
|
||||
const service = await this.getOrCreateService();
|
||||
await service.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user