feat(ollama): main wiring — health.start + before-quit stop (#1 v0.2.3)

This commit is contained in:
altair823
2026-05-02 01:34:33 +09:00
parent a68ffe0aeb
commit e30e436051

View File

@@ -69,8 +69,22 @@ app.whenReady().then(async () => {
fromEnv: process.env.INKLING_OLLAMA_ENDPOINT !== undefined
});
const provider = new LocalOllamaProvider({ endpoint: resolvedEndpoint });
const health = new HealthChecker(provider);
void health.runOnce().then((h) => logger.info('ai.health', { ...h } as Record<string, unknown>));
const health = new HealthChecker(provider, {
onUpdate: (status) => {
logger.info('ai.health', { ...status } as Record<string, unknown>);
// pushOllamaStatus 추가는 Task 4 에서 — helper 부재 시점.
},
onTelemetry: (ev) => {
if (ev.kind === 'ollama_unreachable') {
void telemetry.emit({ kind: 'ollama_unreachable', payload: { reason: ev.reason } }).catch(() => {});
} else if (ev.kind === 'ollama_recovered') {
void telemetry.emit({ kind: 'ollama_recovered', payload: { downtimeMs: ev.downtimeMs } }).catch(() => {});
} else if (ev.kind === 'ollama_recheck_manual') {
void telemetry.emit({ kind: 'ollama_recheck_manual', payload: {} }).catch(() => {});
}
}
});
health.start();
const worker = new AiWorker(repo, provider, {
onUpdate: (note) => {
@@ -128,6 +142,7 @@ app.whenReady().then(async () => {
let backupOnQuitDone = false;
app.on('before-quit', (e) => {
health.stop();
if (backupOnQuitDone) return;
e.preventDefault();
backup.runDaily()