fix(fleet): complete HB reader/writer consistency + sidecar hardening (#599)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #599.
This commit is contained in:
@@ -152,13 +152,16 @@ export function resolveFleetPaths(mosaicHome = defaultMosaicHome()): FleetPaths
|
||||
}
|
||||
|
||||
function defaultMosaicHome(): string {
|
||||
return join(homedir(), '.config', 'mosaic');
|
||||
// Honor MOSAIC_HOME so the reader matches the writer sidecar (and the launcher),
|
||||
// even when MOSAIC_HOME is set in the shell without an explicit --mosaic-home flag.
|
||||
return process.env.MOSAIC_HOME ?? join(homedir(), '.config', 'mosaic');
|
||||
}
|
||||
|
||||
function assertDefaultMosaicHomeForSystemd(mosaicHome: string): void {
|
||||
if (resolve(mosaicHome) !== resolve(defaultMosaicHome())) {
|
||||
const literalHome = join(homedir(), '.config', 'mosaic');
|
||||
if (resolve(mosaicHome) !== resolve(literalHome)) {
|
||||
throw new Error(
|
||||
`install-systemd only supports the default Mosaic home (${defaultMosaicHome()}) because the user systemd units use %h/.config/mosaic paths.`,
|
||||
`install-systemd only supports the default Mosaic home (${literalHome}) because the user systemd units use %h/.config/mosaic paths.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -475,7 +478,10 @@ export function parseTmuxListSessions(output: string): string[] {
|
||||
* Returns the heartbeat file path for an agent.
|
||||
*/
|
||||
export function heartbeatPath(agentName: string, mosaicHome = defaultMosaicHome()): string {
|
||||
return join(mosaicHome, 'fleet', 'run', `${agentName}.hb`);
|
||||
// Honor MOSAIC_HEARTBEAT_RUN_DIR (the writer sidecar's override); otherwise the
|
||||
// canonical <mosaicHome>/fleet/run. Keeps reader and writer on the same path.
|
||||
const runDir = process.env.MOSAIC_HEARTBEAT_RUN_DIR ?? join(mosaicHome, 'fleet', 'run');
|
||||
return join(runDir, `${agentName}.hb`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user