Release agent@1.1.1: stats during jobs, its real version

Stats go every minute on their own timer, also while a job runs (before,
a 30-minute install made the Hub alert that the server was down). The
version constant said 1.0.1 in 1.1.0; a test keeps it equal to
package.json now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 19:03:19 +02:00
co-authored by Claude Opus 5.5
parent 2aab5918f7
commit 43189c599a
7 changed files with 70 additions and 10 deletions
+23 -7
View File
@@ -214,17 +214,33 @@ export class Agent {
}
}
/** Runs until stopped: polls and stats on their own timers, never at the same time as a job. */
/**
* Runs until stopped. Stats go on their own timer, every `statsSeconds`, also while a job runs:
* an install or update can take 30 minutes, and before 1.1.1 the agent went quiet for all of it,
* so the Hub reported it as down (and emailed) though it was busy. Polls wait for the job.
*/
async start(): Promise<void> {
log(`[agent] ${AGENT_VERSION} (${this.deps.config.mode}) for ${this.deps.config.serverId}, Hub ${this.deps.config.hubUrl}`);
let nextStats = 0;
while (!this.stopped) {
if (Date.now() >= nextStats) {
let sending = false;
const statsTick = async () => {
if (sending || this.stopped) return;
sending = true;
try {
await this.statsOnce();
nextStats = Date.now() + this.deps.config.statsSeconds * 1000;
} finally {
sending = false;
}
const delay = await this.pollOnce();
await new Promise((r) => setTimeout(r, Math.max(5, Math.min(delay, this.deps.config.statsSeconds)) * 1000));
};
void statsTick();
const timer = setInterval(() => void statsTick(), this.deps.config.statsSeconds * 1000);
try {
while (!this.stopped) {
const delay = await this.pollOnce();
if (this.stopped) break;
await new Promise((r) => setTimeout(r, Math.max(5, delay) * 1000));
}
} finally {
clearInterval(timer);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ import { paths } from "./paths";
* the tools that are there; anything missing is null rather than an error.
*/
export const AGENT_VERSION = "1.0.1";
export const AGENT_VERSION = "1.1.1";
function run(cmd: string, args: string[], timeoutMs = 10_000): Promise<string | null> {
return new Promise((resolve) => {