mirror of
https://github.com/Zetaphor/browser-recall.git
synced 2025-12-06 02:19:37 +00:00
Move history crawl interval to env
This commit is contained in:
@@ -10,4 +10,5 @@ dependencies = [
|
|||||||
"uvicorn[standard]",
|
"uvicorn[standard]",
|
||||||
"crawl4ai",
|
"crawl4ai",
|
||||||
"browser-history",
|
"browser-history",
|
||||||
|
"python-dotenv"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ from base_crawler import BaseCrawler
|
|||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from browser_history import get_history
|
from browser_history import get_history
|
||||||
|
from dotenv import load_dotenv
|
||||||
# Create logs directory if it doesn't exist
|
# Create logs directory if it doesn't exist
|
||||||
os.makedirs('logs', exist_ok=True)
|
os.makedirs('logs', exist_ok=True)
|
||||||
|
|
||||||
|
# Load environment variables
|
||||||
|
load_dotenv()
|
||||||
|
CRAWL_INTERVAL = int(os.getenv('CRAWL_INTERVAL', 30)) # Default to 30 seconds if not set
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
# Startup
|
# Startup
|
||||||
@@ -62,7 +67,7 @@ class HistoryCrawler(BaseCrawler):
|
|||||||
if success:
|
if success:
|
||||||
self.logger.info(f"Processed historical URL: {url}")
|
self.logger.info(f"Processed historical URL: {url}")
|
||||||
|
|
||||||
await asyncio.sleep(30) # Wait 30 seconds before next crawl
|
await asyncio.sleep(CRAWL_INTERVAL) # Use environment variable for interval
|
||||||
|
|
||||||
@app.websocket("/ws")
|
@app.websocket("/ws")
|
||||||
async def websocket_endpoint(websocket: WebSocket):
|
async def websocket_endpoint(websocket: WebSocket):
|
||||||
|
|||||||
2
uv.lock
generated
2
uv.lock
generated
@@ -197,6 +197,7 @@ dependencies = [
|
|||||||
{ name = "browser-history" },
|
{ name = "browser-history" },
|
||||||
{ name = "crawl4ai" },
|
{ name = "crawl4ai" },
|
||||||
{ name = "fastapi" },
|
{ name = "fastapi" },
|
||||||
|
{ name = "python-dotenv" },
|
||||||
{ name = "uvicorn", extra = ["standard"] },
|
{ name = "uvicorn", extra = ["standard"] },
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -205,6 +206,7 @@ requires-dist = [
|
|||||||
{ name = "browser-history" },
|
{ name = "browser-history" },
|
||||||
{ name = "crawl4ai" },
|
{ name = "crawl4ai" },
|
||||||
{ name = "fastapi" },
|
{ name = "fastapi" },
|
||||||
|
{ name = "python-dotenv" },
|
||||||
{ name = "uvicorn", extras = ["standard"] },
|
{ name = "uvicorn", extras = ["standard"] },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user