fix: automatically close opencode process when exiting openchamber (closes #927) (#947)

This commit is contained in:
ricautomation
2026-04-21 23:02:01 +03:00
committed by GitHub
parent 3509a5f98b
commit 45f8d6c2be
4 changed files with 81 additions and 35 deletions
+3 -1
View File
@@ -71,6 +71,7 @@
"@types/react": "^19.1.10",
"@types/react-dom": "^19.1.7",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/supertest": "^7.2.0",
"@vitejs/plugin-react": "^5.0.0",
"autoprefixer": "^10.4.21",
"class-variance-authority": "^0.7.1",
@@ -94,6 +95,7 @@
"sonner": "^2.0.7",
"strip-json-comments": "^5.0.3",
"tailwind-merge": "^3.3.1",
"supertest": "^7.2.2",
"tailwindcss": "^4.0.0",
"tsx": "^4.20.6",
"tw-animate-css": "^1.3.8",
@@ -101,7 +103,7 @@
"typescript-eslint": "^8.39.1",
"vite": "^7.1.2",
"vite-plugin-pwa": "^1.0.3",
"vitest": "^3.0.5",
"vitest": "^4.1.4",
"workbox-window": "^7.4.0",
"zustand": "^5.0.8"
},
@@ -18,7 +18,7 @@ export const registerServerStatusRoutes = (app, dependencies) => {
app.post('/api/system/shutdown', (_req, res) => {
res.json({ ok: true });
gracefulShutdown({ exitProcess: false }).catch((error) => {
gracefulShutdown({ exitProcess: true }).catch((error) => {
console.error('Shutdown request failed:', error?.message || error);
});
});
@@ -0,0 +1,26 @@
import { describe, it, expect, vi } from 'vitest';
import express from 'express';
import request from 'supertest';
import { registerServerStatusRoutes } from './core-routes.js';
describe('core-routes', () => {
it('should call gracefulShutdown with exitProcess: true on /api/system/shutdown', async () => {
const app = express();
let shutdownOpts = null;
const dependencies = {
gracefulShutdown: vi.fn(async (opts) => {
shutdownOpts = opts;
}),
getHealthSnapshot: () => ({ status: 'ok' }),
openchamberVersion: '1.0.0',
runtimeName: 'test',
};
registerServerStatusRoutes(app, dependencies);
await request(app).post('/api/system/shutdown');
expect(dependencies.gracefulShutdown).toHaveBeenCalled();
expect(shutdownOpts).toEqual({ exitProcess: true });
});
});