Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(console): stop a hung Docker server before restarting it
Simon Flack2302490b26e3
diff --git a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.test.ts b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.test.tsindex bf4ea6ee6..9285c05d9 100644--- a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.test.ts@@ -890,3 +890,41 @@ it('watches a server set up after launch, on a first install', async () => {vi.useRealTimers();}});++it('stops a hung Docker server before restarting it, since compose up would leave it', async () => {+ m.version.mockResolvedValue({ deployedVersion: '0.11.0', drift: null });+ const service = new LocalServerService();+ await boot(service);+ images.mockResolvedValue(new Map([['switch', 'switch:0.11.0']]));+ watch.health.mockResolvedValue(false);+ await service.watch();+ await service.watch();+ await service.watch();+ expect(service.getStatus()).toMatchObject({ phase: 'error', failedTo: 'run' });++ const order: string[] = [];+ m.stop.mockImplementation(async () => {+ order.push('stop');+ });+ m.start.mockImplementation(async () => {+ order.push('start');+ return started;+ });+ expect(await service.start()).toEqual(started);++ expect(order).toEqual(['stop', 'start']);+ expect(service.getStatus().phase).toBe('running');+});++it('does not stop a Docker server first on an ordinary start', async () => {+ m.running.mockResolvedValue(false);+ m.version.mockResolvedValue({ deployedVersion: '0.11.0', drift: null });+ m.start.mockResolvedValue(started);+ const service = new LocalServerService();+ await boot(service);++ await service.start();++ expect(m.stop).not.toHaveBeenCalled();+ expect(m.start).toHaveBeenCalledOnce();+});diff --git a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.ts b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.tsindex dd60fe80a..dfc8bf9ed 100644--- a/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.ts+++ b/console/apps/switch-console-desktop/src/main/core/managed-switch-server/local-server-service.ts@@ -571,6 +571,9 @@ export class LocalServerService {this.startAbort = new AbortController();const host: ServerHost = new LocalServerHost();const checkoutRoot = this.checkoutRootForStart();+ // Read before the phase moves on: whether this start is the way back from+ // a server that stopped, or stopped answering, on its own.+ const recovering = this.status.phase === 'error' && this.status.failedTo === 'run';try {const runtime = await this.runtime();// A server still on Docker moves itself to the native runtime, data and@@ -629,6 +632,13 @@ export class LocalServerService {result = started.result;bringUpMattermost = started.bringUpMattermost;} else {+ // `compose up` leaves a container that is running alone, however hung+ // it is, so a server that stopped answering is stopped first. The+ // native start and the move off Docker stop everything themselves.+ if (recovering) {+ common.onMessage('Stopping the server that stopped answering…');+ await stopStack(host, null);+ }// Nobody else shares the local stack, so there is nothing to lock.result = await startStack({ ...common, lease: null });}