mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: sse for volume status change
This commit is contained in:
@@ -75,7 +75,7 @@ export const eventsController = new Hono().get("/", (c) => {
|
||||
data: JSON.stringify({ timestamp: Date.now() }),
|
||||
event: "heartbeat",
|
||||
});
|
||||
await stream.sleep(30000);
|
||||
await stream.sleep(5000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -224,6 +224,10 @@ const checkHealth = async (name: string) => {
|
||||
const backend = createVolumeBackend(volume);
|
||||
const { error, status } = await backend.checkHealth();
|
||||
|
||||
if (status !== volume.status) {
|
||||
serverEvents.emit("volume:status_changed", { volumeName: name, status });
|
||||
}
|
||||
|
||||
await db
|
||||
.update(volumesTable)
|
||||
.set({ lastHealthCheck: Date.now(), status, lastError: error ?? null })
|
||||
|
||||
Reference in New Issue
Block a user