Move history crawl interval to env

This commit is contained in:
zetaphor committed 2025-04-12 14:45:59 -05:00
1 parent 5629a92acf
commit 6307d962d8
4 files changed
+10 -1

No files matched your search

+6 -1
View File
@@ -10,9 +10,14 @@ from base_crawler import BaseCrawler
import asyncio
from contextlib import asynccontextmanager
from browser_history import get_history
from dotenv import load_dotenv
# Create logs directory if it doesn't exist
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
async def lifespan(app: FastAPI):
# Startup
@@ -62,7 +67,7 @@ class HistoryCrawler(BaseCrawler):
if success:
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")
async def websocket_endpoint(websocket: WebSocket):