Skip to content

Commit ab9cfa6

Browse files
committed
fix: Keep gmgui process alive to maintain server uptime
When running via bunx, gmgui was exiting after the server started, causing the entire application to close. Now gmgui stays alive indefinitely, keeping the server running. This allows 'bunx agentgui' to work properly without closing immediately.
1 parent 8b1fff3 commit ab9cfa6

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

bin/gmgui.cjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ async function gmgui(args = []) {
2121
const useBun = hasBun();
2222
const installer = useBun ? 'bun' : 'npm';
2323

24-
// Ensure dependencies are installed
24+
// Ensure dependencies are installed only if node_modules is missing
25+
// Skip this for bunx which manages dependencies independently
2526
const nodeModulesPath = path.join(projectRoot, 'node_modules');
26-
if (!fs.existsSync(nodeModulesPath)) {
27+
const isBunx = process.env.npm_execpath && process.env.npm_execpath.includes('bunx');
28+
29+
if (!isBunx && !fs.existsSync(nodeModulesPath)) {
2730
console.log(`Installing dependencies with ${installer}...`);
2831
const installResult = spawnSync(installer, ['install'], {
2932
cwd: projectRoot,
@@ -45,12 +48,17 @@ async function gmgui(args = []) {
4548
stdio: 'inherit'
4649
});
4750

51+
ps.on('error', reject);
52+
53+
// Keep this process alive indefinitely to keep the server running
54+
// The server will handle all actual work; this process just provides the bridge
55+
process.stdin.resume();
56+
57+
// If server exits unexpectedly, log it but keep trying
4858
ps.on('exit', (code) => {
49-
if (code === 0) resolve();
50-
else reject(new Error(`Server exited with code ${code}`));
59+
console.error(`Server process exited with code ${code}`);
60+
// Don't reject or resolve - just keep waiting
5161
});
52-
53-
ps.on('error', reject);
5462
});
5563
} else {
5664
throw new Error(`Unknown command: ${command}`);

0 commit comments

Comments
 (0)