Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,13 @@ from collections import defaultdict
|
|
| 28 |
from contextlib import asynccontextmanager
|
| 29 |
from typing import Optional, List, AsyncGenerator
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
from fastapi import FastAPI, HTTPException, Request
|
| 32 |
from fastapi.middleware.cors import CORSMiddleware
|
| 33 |
from fastapi.staticfiles import StaticFiles
|
|
@@ -762,10 +769,16 @@ async def health():
|
|
| 762 |
The `sources` block is the honest answer to "where do this system's facts
|
| 763 |
come from, and are those sources actually reachable right now?"
|
| 764 |
"""
|
|
|
|
| 765 |
return {
|
| 766 |
"status": "ok",
|
| 767 |
"service": "ResearchBee",
|
| 768 |
"version": "1.4.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
"sources": {
|
| 770 |
"oaworks": {
|
| 771 |
"endpoint": oaworks.OA_WORKS_BASE + oaworks.PERMISSIONS_PATH,
|
|
|
|
| 28 |
from contextlib import asynccontextmanager
|
| 29 |
from typing import Optional, List, AsyncGenerator
|
| 30 |
|
| 31 |
+
# Process boot time, captured at import so it is set before any heavy
|
| 32 |
+
# module-level work and before lifespan runs. Exposed on /api/health so
|
| 33 |
+
# the uptime monitor can distinguish "still running" from "died and came
|
| 34 |
+
# back between polls" — a restarted container reports RUNNING and 200 at
|
| 35 |
+
# both polls, but its boot_ts moves.
|
| 36 |
+
BOOT_TS = time.time()
|
| 37 |
+
|
| 38 |
from fastapi import FastAPI, HTTPException, Request
|
| 39 |
from fastapi.middleware.cors import CORSMiddleware
|
| 40 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 769 |
The `sources` block is the honest answer to "where do this system's facts
|
| 770 |
come from, and are those sources actually reachable right now?"
|
| 771 |
"""
|
| 772 |
+
now = time.time()
|
| 773 |
return {
|
| 774 |
"status": "ok",
|
| 775 |
"service": "ResearchBee",
|
| 776 |
"version": "1.4.0",
|
| 777 |
+
# Restart detection for the uptime monitor. boot_ts is the stable
|
| 778 |
+
# identity of this process; when it changes between two polls the
|
| 779 |
+
# container was replaced, whatever the HTTP status said.
|
| 780 |
+
"boot_ts": round(BOOT_TS, 3),
|
| 781 |
+
"uptime_s": round(now - BOOT_TS, 1),
|
| 782 |
"sources": {
|
| 783 |
"oaworks": {
|
| 784 |
"endpoint": oaworks.OA_WORKS_BASE + oaworks.PERMISSIONS_PATH,
|