Skip to content

Commit dc7eb6a

Browse files
committed
Fix storage of last_seen in state file
1 parent 9070fd2 commit dc7eb6a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lvmbeat/monitor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ async def lifespan(app: FastAPI):
8080
active = bool(int(data.split(",")[0]))
8181
last_seen = data.split(",")[1]
8282

83-
logger.info(f"Restoring state. active={active}, last_seen={last_seen}.")
84-
app.state.last_seen = last_seen if last_seen else None
83+
app.state.last_seen = float(last_seen) if last_seen else None
8584
app.state.active = active
85+
86+
logger.info(
87+
f"Restoring state to active={app.state.active!r}, "
88+
f"last_seen={timestamp_to_iso(app.state.last_seen)!r}."
89+
)
8690
except Exception as e:
8791
logger.error(f"Could not read state file: {e}")
8892
logger.error("Removing corrupted state file.")

0 commit comments

Comments
 (0)