Spaces:
Runtime error
Runtime error
Fix Error Time Out
Browse files- Dockerfile +2 -2
- app.py +18 -1
- gunicorn_config.py +29 -0
- huggingface.yml +7 -0
Dockerfile
CHANGED
|
@@ -23,5 +23,5 @@ RUN mkdir -p /tmp/42coderunner
|
|
| 23 |
# Exponer el puerto
|
| 24 |
EXPOSE 5000
|
| 25 |
|
| 26 |
-
# Comando para ejecutar la aplicaci贸n
|
| 27 |
-
CMD ["gunicorn", "--
|
|
|
|
| 23 |
# Exponer el puerto
|
| 24 |
EXPOSE 5000
|
| 25 |
|
| 26 |
+
# Comando para ejecutar la aplicaci贸n con archivo de configuraci贸n
|
| 27 |
+
CMD ["gunicorn", "--config", "gunicorn_config.py", "app:app"]
|
app.py
CHANGED
|
@@ -99,7 +99,24 @@ def execute_code():
|
|
| 99 |
|
| 100 |
@app.route('/api/health', methods=['GET'])
|
| 101 |
def health_check():
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
if __name__ == '__main__':
|
| 105 |
port = int(os.environ.get('PORT', 5000))
|
|
|
|
| 99 |
|
| 100 |
@app.route('/api/health', methods=['GET'])
|
| 101 |
def health_check():
|
| 102 |
+
# Verificar que el directorio temporal existe
|
| 103 |
+
temp_dir_exists = os.path.exists(TEMP_DIR)
|
| 104 |
+
|
| 105 |
+
# Verificar que podemos compilar c贸digo C
|
| 106 |
+
compiler_available = True
|
| 107 |
+
try:
|
| 108 |
+
subprocess.run(['gcc', '--version'], capture_output=True, check=True)
|
| 109 |
+
except (subprocess.SubprocessError, FileNotFoundError):
|
| 110 |
+
compiler_available = False
|
| 111 |
+
|
| 112 |
+
return jsonify({
|
| 113 |
+
'status': 'ok',
|
| 114 |
+
'timestamp': time.time(),
|
| 115 |
+
'environment': {
|
| 116 |
+
'temp_dir': temp_dir_exists,
|
| 117 |
+
'compiler': compiler_available
|
| 118 |
+
}
|
| 119 |
+
})
|
| 120 |
|
| 121 |
if __name__ == '__main__':
|
| 122 |
port = int(os.environ.get('PORT', 5000))
|
gunicorn_config.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gunicorn configuration file
|
| 2 |
+
import multiprocessing
|
| 3 |
+
|
| 4 |
+
# Server socket
|
| 5 |
+
bind = "0.0.0.0:5000"
|
| 6 |
+
|
| 7 |
+
# Worker processes
|
| 8 |
+
workers = 2
|
| 9 |
+
worker_class = "sync"
|
| 10 |
+
threads = 2
|
| 11 |
+
|
| 12 |
+
# Timeout settings
|
| 13 |
+
timeout = 120
|
| 14 |
+
keepalive = 2
|
| 15 |
+
|
| 16 |
+
# Server mechanics
|
| 17 |
+
preload_app = True
|
| 18 |
+
|
| 19 |
+
# Logging
|
| 20 |
+
accesslog = "-"
|
| 21 |
+
errorlog = "-"
|
| 22 |
+
loglevel = "info"
|
| 23 |
+
|
| 24 |
+
# Health check settings
|
| 25 |
+
def on_starting(server):
|
| 26 |
+
print("Gunicorn server is starting up...")
|
| 27 |
+
|
| 28 |
+
def when_ready(server):
|
| 29 |
+
print("Gunicorn server is ready. Health check should now respond.")
|
huggingface.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
build_dir: .
|
| 2 |
+
health_check:
|
| 3 |
+
type: http
|
| 4 |
+
url: /api/health
|
| 5 |
+
interval: 10
|
| 6 |
+
timeout: 5
|
| 7 |
+
retries: 3
|