Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: reapply saved llama.cpp idle setting on upgrade

[._.]/ Adam Eivyc1a5ad5f4472
diff --git a/server/services/llamaServerManager.js b/server/services/llamaServerManager.js
index 52bcc49b53..a3b44371f0 100644
--- a/server/services/llamaServerManager.js
+++ b/server/services/llamaServerManager.js
@@ -728,7 +728,10 @@ const waitForPortRelease = daemon.waitForPortRelease;
*/
async function restartManagedLlamaServer(config, baseline) {
await waitForPortRelease(config.port ?? PORTS.LLAMA_SERVER);
- const started = await startLlamaServer(config).catch((err) => {
+ // The recovered PM2 config carries the effective idle flag from the old
+ // process. Leave this field undefined so startLlamaServer reads the current
+ // saved setting when an upgrade is also the next launch.
+ const started = await startLlamaServer({ ...config, sleepIdleMinutes: undefined }).catch((err) => {
console.error(`❌ llama-server: could not restore the previous configuration after update: ${err.message}`);
return null;
});
diff --git a/server/services/llamaServerManager.test.js b/server/services/llamaServerManager.test.js
index 6ac1e1f7cf..dc670090a7 100644
--- a/server/services/llamaServerManager.test.js
+++ b/server/services/llamaServerManager.test.js
@@ -682,6 +682,32 @@ describe('llamaServerManager', () => {
expect(startCall).toContain('example-model');
});
+ it('restarts a managed server with the current saved idle window', async () => {
+ const binaryPath = homebrewBinaryPath;
+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(binaryPath);
+ stubBrewInfo();
+ pm2State = {
+ name: LLAMA_APP,
+ status: 'online',
+ pid: 321,
+ args: ['-m', modelPath, '--port', String(PORTS.LLAMA_SERVER), '--sleep-idle-seconds', '0'],
+ };
+ openAiModelsProbe.probeOpenAiModels.mockImplementation(async () => ({ reachable: pm2State?.status === 'online' }));
+ vi.spyOn(childProcess, 'execFile').mockImplementation((_bin, _args, _opts, cb) => {
+ cb(null, '--sleep-idle-seconds SECONDS', '');
+ return fakeSpawnProcess();
+ });
+ vi.spyOn(streamingSpawnModule, 'runStreamingCommand').mockResolvedValue({ success: true });
+ _resetLlamaServerStateForTests({ sleepIdleMinutes: 30 });
+
+ const result = await upgradeLlamaServer();
+
+ expect(result).toMatchObject({ success: true });
+ const startCall = execPm2Calls.find((args) => args[0] === 'start');
+ const idleFlagIndex = startCall.indexOf('--sleep-idle-seconds');
+ expect(startCall[idleFlagIndex + 1]).toBe('1800');
+ });
+
it('refuses to update when PM2 ownership cannot be determined', async () => {
vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(homebrewBinaryPath);
stubBrewInfo();