fix(runner): restart when hub identity changes (#303)

* fix(runner): restart when hub identity changes

* fix(runner): fail closed on missing identity
This commit is contained in:
ROOOO
2026-03-18 10:43:36 +08:00
committed by GitHub
parent 2ecd56dbe8
commit f967bd9928
5 changed files with 173 additions and 5 deletions
+8
View File
@@ -7,6 +7,7 @@ import { RunnerState, Metadata } from '@/api/types';
import { SpawnSessionOptions, SpawnSessionResult } from '@/modules/common/rpcTypes';
import { logger } from '@/ui/logger';
import { authAndSetupMachineIfNeeded } from '@/ui/auth';
import { configuration } from '@/configuration';
import packageJson from '../../package.json';
import { getEnvironmentInfo } from '@/ui/doctor';
import { spawnHappyCLI } from '@/utils/spawnHappyCLI';
@@ -20,6 +21,7 @@ import { startRunnerControlServer } from './controlServer';
import { createWorktree, removeWorktree, type WorktreeInfo } from './worktree';
import { join } from 'path';
import { buildMachineMetadata } from '@/agent/sessionFactory';
import { hashRunnerCliApiToken } from './runnerIdentity';
export async function startRunner(): Promise<void> {
// We don't have cleanup function at the time of server construction
@@ -629,6 +631,9 @@ export async function startRunner(): Promise<void> {
startTime: new Date().toLocaleString(),
startedWithCliVersion: packageJson.version,
startedWithCliMtimeMs,
startedWithApiUrl: configuration.apiUrl,
startedWithMachineId: machineId,
startedWithCliApiTokenHash: hashRunnerCliApiToken(configuration.cliApiToken),
runnerLogPath: logger.logFilePath
};
writeRunnerState(fileState);
@@ -788,6 +793,9 @@ export async function startRunner(): Promise<void> {
startTime: fileState.startTime,
startedWithCliVersion: packageJson.version,
startedWithCliMtimeMs,
startedWithApiUrl: fileState.startedWithApiUrl,
startedWithMachineId: fileState.startedWithMachineId,
startedWithCliApiTokenHash: fileState.startedWithCliApiTokenHash,
lastHeartbeat: new Date().toLocaleString(),
runnerLogPath: fileState.runnerLogPath
};