Audit Report: Hugging Face Production Crash (Health Check Timeout)
1. Incident Description
The production environment hosted on Hugging Face Spaces was experiencing systematic crashes after approximately 30 minutes of uptime. The error reported was: Launch timed out, workload was not healthy after 30 min.
2. Diagnostic
Hugging Face Spaces requires the container to listen on a specific port (defaulting to 7860) to perform its internal health checks (pings).
Analysis of the logs showed that the Edtech API was listening on port 8080:
[STARTUP] Server listening on http://0.0.0.0:8080
Because the health check pings were directed at port 7860 and received no response, Hugging Face flagged the service as "unhealthy" and terminated the container after the 30-minute grace period.
3. Implementation of the Patch
The startup logic of the API and the container configuration have been modified to prioritize the Hugging Face standard port 7860.
3.1. API Server Change
File modified: apps/api/src/index.ts
Code change:
- const port = parseInt(process.env.PORT || '8080');
+ const port = parseInt(process.env.PORT || '7860');
3.2. Docker Configuration Change
File modified: Dockerfile
Code change:
- EXPOSE 8080 8082
+ EXPOSE 7860 8082
3.3. PM2 Process Configuration Change
File modified: ecosystem.config.js
Code change:
- PORT: 8080
+ PORT: 7860
4. Validation
- Local Testing: The API now starts on port 7860 by default if no environment variable is provided.
- Production Testing: After deploying the patch, the Hugging Face health check successfully connects to port 7860. The service remains "Healthy" and the container is no longer terminated after 30 minutes.
Status: Resolved Last Updated: 2026-05-07 15:06 (Force Redeploy) Author: Antigravity (AI Coding Assistant)