fix(daemon): Fix smartipc integration and add daemon/ipc integration tests
This commit is contained in:
		@@ -3,6 +3,6 @@
 | 
			
		||||
 */
 | 
			
		||||
export const commitinfo = {
 | 
			
		||||
  name: '@git.zone/tspm',
 | 
			
		||||
  version: '1.6.0',
 | 
			
		||||
  version: '1.6.1',
 | 
			
		||||
  description: 'a no fuzz process manager'
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -40,9 +40,10 @@ export class TspmDaemon {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Initialize IPC server
 | 
			
		||||
    this.ipcServer = new plugins.smartipc.IpcServer({
 | 
			
		||||
    this.ipcServer = plugins.smartipc.SmartIpc.createServer({
 | 
			
		||||
      id: 'tspm-daemon',
 | 
			
		||||
      socketPath: this.socketPath,
 | 
			
		||||
      heartbeat: false,  // Disable heartbeat for now
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Register message handlers
 | 
			
		||||
@@ -72,9 +73,9 @@ export class TspmDaemon {
 | 
			
		||||
   */
 | 
			
		||||
  private registerHandlers(): void {
 | 
			
		||||
    // Process management handlers
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'start'>>(
 | 
			
		||||
    this.ipcServer.onMessage(
 | 
			
		||||
      'start',
 | 
			
		||||
      async (request) => {
 | 
			
		||||
      async (request: RequestForMethod<'start'>) => {
 | 
			
		||||
        try {
 | 
			
		||||
          await this.tspmInstance.start(request.config);
 | 
			
		||||
          const processInfo = this.tspmInstance.processInfo.get(
 | 
			
		||||
@@ -91,9 +92,9 @@ export class TspmDaemon {
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'stop'>>(
 | 
			
		||||
    this.ipcServer.onMessage(
 | 
			
		||||
      'stop',
 | 
			
		||||
      async (request) => {
 | 
			
		||||
      async (request: RequestForMethod<'stop'>) => {
 | 
			
		||||
        try {
 | 
			
		||||
          await this.tspmInstance.stop(request.id);
 | 
			
		||||
          return {
 | 
			
		||||
@@ -106,7 +107,7 @@ export class TspmDaemon {
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'restart'>>('restart', async (request) => {
 | 
			
		||||
    this.ipcServer.onMessage('restart', async (request: RequestForMethod<'restart'>) => {
 | 
			
		||||
      try {
 | 
			
		||||
        await this.tspmInstance.restart(request.id);
 | 
			
		||||
        const processInfo = this.tspmInstance.processInfo.get(request.id);
 | 
			
		||||
@@ -120,9 +121,9 @@ export class TspmDaemon {
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'delete'>>(
 | 
			
		||||
    this.ipcServer.onMessage(
 | 
			
		||||
      'delete',
 | 
			
		||||
      async (request) => {
 | 
			
		||||
      async (request: RequestForMethod<'delete'>) => {
 | 
			
		||||
        try {
 | 
			
		||||
          await this.tspmInstance.delete(request.id);
 | 
			
		||||
          return {
 | 
			
		||||
@@ -136,15 +137,15 @@ export class TspmDaemon {
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // Query handlers
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'list'>>(
 | 
			
		||||
    this.ipcServer.onMessage(
 | 
			
		||||
      'list',
 | 
			
		||||
      async () => {
 | 
			
		||||
      async (request: RequestForMethod<'list'>) => {
 | 
			
		||||
        const processes = await this.tspmInstance.list();
 | 
			
		||||
        return { processes };
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'describe'>>('describe', async (request) => {
 | 
			
		||||
    this.ipcServer.onMessage('describe', async (request: RequestForMethod<'describe'>) => {
 | 
			
		||||
      const processInfo = await this.tspmInstance.describe(request.id);
 | 
			
		||||
      const config = this.tspmInstance.processConfigs.get(request.id);
 | 
			
		||||
 | 
			
		||||
@@ -158,13 +159,13 @@ export class TspmDaemon {
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'getLogs'>>('getLogs', async (request) => {
 | 
			
		||||
    this.ipcServer.onMessage('getLogs', async (request: RequestForMethod<'getLogs'>) => {
 | 
			
		||||
      const logs = await this.tspmInstance.getLogs(request.id);
 | 
			
		||||
      return { logs };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Batch operations handlers
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'startAll'>>('startAll', async () => {
 | 
			
		||||
    this.ipcServer.onMessage('startAll', async (request: RequestForMethod<'startAll'>) => {
 | 
			
		||||
      const started: string[] = [];
 | 
			
		||||
      const failed: Array<{ id: string; error: string }> = [];
 | 
			
		||||
 | 
			
		||||
@@ -182,7 +183,7 @@ export class TspmDaemon {
 | 
			
		||||
      return { started, failed };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'stopAll'>>('stopAll', async () => {
 | 
			
		||||
    this.ipcServer.onMessage('stopAll', async (request: RequestForMethod<'stopAll'>) => {
 | 
			
		||||
      const stopped: string[] = [];
 | 
			
		||||
      const failed: Array<{ id: string; error: string }> = [];
 | 
			
		||||
 | 
			
		||||
@@ -200,7 +201,7 @@ export class TspmDaemon {
 | 
			
		||||
      return { stopped, failed };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'restartAll'>>('restartAll', async () => {
 | 
			
		||||
    this.ipcServer.onMessage('restartAll', async (request: RequestForMethod<'restartAll'>) => {
 | 
			
		||||
      const restarted: string[] = [];
 | 
			
		||||
      const failed: Array<{ id: string; error: string }> = [];
 | 
			
		||||
 | 
			
		||||
@@ -219,7 +220,7 @@ export class TspmDaemon {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Daemon management handlers
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'daemon:status'>>('daemon:status', async () => {
 | 
			
		||||
    this.ipcServer.onMessage('daemon:status', async (request: RequestForMethod<'daemon:status'>) => {
 | 
			
		||||
      const memUsage = process.memoryUsage();
 | 
			
		||||
      return {
 | 
			
		||||
        status: 'running',
 | 
			
		||||
@@ -231,7 +232,7 @@ export class TspmDaemon {
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'daemon:shutdown'>>('daemon:shutdown', async (request) => {
 | 
			
		||||
    this.ipcServer.onMessage('daemon:shutdown', async (request: RequestForMethod<'daemon:shutdown'>) => {
 | 
			
		||||
      if (this.isShuttingDown) {
 | 
			
		||||
        return {
 | 
			
		||||
          success: false,
 | 
			
		||||
@@ -256,7 +257,7 @@ export class TspmDaemon {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Heartbeat handler
 | 
			
		||||
    this.ipcServer.on<RequestForMethod<'heartbeat'>>('heartbeat', async () => {
 | 
			
		||||
    this.ipcServer.onMessage('heartbeat', async (request: RequestForMethod<'heartbeat'>) => {
 | 
			
		||||
      return {
 | 
			
		||||
        timestamp: Date.now(),
 | 
			
		||||
        status: this.isShuttingDown ? 'degraded' : 'healthy',
 | 
			
		||||
 
 | 
			
		||||
@@ -41,9 +41,10 @@ export class TspmIpcClient {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create IPC client
 | 
			
		||||
    this.ipcClient = new plugins.smartipc.IpcClient({
 | 
			
		||||
    this.ipcClient = plugins.smartipc.SmartIpc.createClient({
 | 
			
		||||
      id: 'tspm-cli',
 | 
			
		||||
      socketPath: this.socketPath,
 | 
			
		||||
      heartbeat: false,  // Disable heartbeat for now
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Connect to the daemon
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user