mirror of https://github.com/kortix-ai/suna.git
unlimited requests per worker, deactivate restore_running_agent_runs
This commit is contained in:
parent
cae19692e1
commit
032375fdc5
|
@ -46,8 +46,8 @@ CMD ["sh", "-c", "gunicorn api:app \
|
||||||
--timeout 1800 \
|
--timeout 1800 \
|
||||||
--graceful-timeout 600 \
|
--graceful-timeout 600 \
|
||||||
--keep-alive 1800 \
|
--keep-alive 1800 \
|
||||||
--max-requests 2000 \
|
--max-requests 0 \
|
||||||
--max-requests-jitter 400 \
|
--max-requests-jitter 0 \
|
||||||
--forwarded-allow-ips '*' \
|
--forwarded-allow-ips '*' \
|
||||||
--worker-connections $WORKER_CONNECTIONS \
|
--worker-connections $WORKER_CONNECTIONS \
|
||||||
--worker-tmp-dir /dev/shm \
|
--worker-tmp-dir /dev/shm \
|
||||||
|
|
|
@ -243,38 +243,38 @@ async def _cleanup_redis_response_list(agent_run_id: str):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to set TTL on response list {response_list_key}: {str(e)}")
|
logger.warning(f"Failed to set TTL on response list {response_list_key}: {str(e)}")
|
||||||
|
|
||||||
async def restore_running_agent_runs():
|
# async def restore_running_agent_runs():
|
||||||
"""Mark agent runs that were still 'running' in the database as failed and clean up Redis resources."""
|
# """Mark agent runs that were still 'running' in the database as failed and clean up Redis resources."""
|
||||||
logger.info("Restoring running agent runs after server restart")
|
# logger.info("Restoring running agent runs after server restart")
|
||||||
client = await db.client
|
# client = await db.client
|
||||||
running_agent_runs = await client.table('agent_runs').select('id').eq("status", "running").execute()
|
# running_agent_runs = await client.table('agent_runs').select('id').eq("status", "running").execute()
|
||||||
|
|
||||||
for run in running_agent_runs.data:
|
# for run in running_agent_runs.data:
|
||||||
agent_run_id = run['id']
|
# agent_run_id = run['id']
|
||||||
logger.warning(f"Found running agent run {agent_run_id} from before server restart")
|
# logger.warning(f"Found running agent run {agent_run_id} from before server restart")
|
||||||
|
|
||||||
# Clean up Redis resources for this run
|
# # Clean up Redis resources for this run
|
||||||
try:
|
# try:
|
||||||
# Clean up active run key
|
# # Clean up active run key
|
||||||
active_run_key = f"active_run:{instance_id}:{agent_run_id}"
|
# active_run_key = f"active_run:{instance_id}:{agent_run_id}"
|
||||||
await redis.delete(active_run_key)
|
# await redis.delete(active_run_key)
|
||||||
|
|
||||||
# Clean up response list
|
# # Clean up response list
|
||||||
response_list_key = f"agent_run:{agent_run_id}:responses"
|
# response_list_key = f"agent_run:{agent_run_id}:responses"
|
||||||
await redis.delete(response_list_key)
|
# await redis.delete(response_list_key)
|
||||||
|
|
||||||
# Clean up control channels
|
# # Clean up control channels
|
||||||
control_channel = f"agent_run:{agent_run_id}:control"
|
# control_channel = f"agent_run:{agent_run_id}:control"
|
||||||
instance_control_channel = f"agent_run:{agent_run_id}:control:{instance_id}"
|
# instance_control_channel = f"agent_run:{agent_run_id}:control:{instance_id}"
|
||||||
await redis.delete(control_channel)
|
# await redis.delete(control_channel)
|
||||||
await redis.delete(instance_control_channel)
|
# await redis.delete(instance_control_channel)
|
||||||
|
|
||||||
logger.info(f"Cleaned up Redis resources for agent run {agent_run_id}")
|
# logger.info(f"Cleaned up Redis resources for agent run {agent_run_id}")
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
logger.error(f"Error cleaning up Redis resources for agent run {agent_run_id}: {e}")
|
# logger.error(f"Error cleaning up Redis resources for agent run {agent_run_id}: {e}")
|
||||||
|
|
||||||
# Call stop_agent_run to handle status update and cleanup
|
# # Call stop_agent_run to handle status update and cleanup
|
||||||
await stop_agent_run(agent_run_id, error_message="Server restarted while agent was running")
|
# await stop_agent_run(agent_run_id, error_message="Server restarted while agent was running")
|
||||||
|
|
||||||
async def check_for_active_project_agent_run(client, project_id: str):
|
async def check_for_active_project_agent_run(client, project_id: str):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -61,7 +61,7 @@ async def lifespan(app: FastAPI):
|
||||||
# Continue without Redis - the application will handle Redis failures gracefully
|
# Continue without Redis - the application will handle Redis failures gracefully
|
||||||
|
|
||||||
# Start background tasks
|
# Start background tasks
|
||||||
asyncio.create_task(agent_api.restore_running_agent_runs())
|
# asyncio.create_task(agent_api.restore_running_agent_runs())
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue