Fix Error not start
Browse files- README.md +1 -1
- app.py +34 -7
- gunicorn_config.py +4 -4
- huggingface.yml +2 -1
- requirements.txt +2 -1
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 馃殌
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
|
|
1 |
---
|
2 |
+
title: MargeCode42
|
3 |
emoji: 馃殌
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
app.py
CHANGED
@@ -104,19 +104,46 @@ def health_check():
|
|
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 |
-
|
|
|
110 |
compiler_available = False
|
|
|
111 |
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
'timestamp': time.time(),
|
115 |
'environment': {
|
116 |
-
'temp_dir':
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
-
}
|
|
|
|
|
|
|
120 |
|
121 |
if __name__ == '__main__':
|
122 |
port = int(os.environ.get('PORT', 5000))
|
|
|
104 |
|
105 |
# Verificar que podemos compilar c贸digo C
|
106 |
compiler_available = True
|
107 |
+
compiler_version = "Unknown"
|
108 |
try:
|
109 |
+
result = subprocess.run(['gcc', '--version'], capture_output=True, text=True, check=True)
|
110 |
+
compiler_version = result.stdout.split('\n')[0] if result.stdout else "Unknown"
|
111 |
+
except (subprocess.SubprocessError, FileNotFoundError) as e:
|
112 |
compiler_available = False
|
113 |
+
logger.error(f"Error al verificar el compilador: {e}")
|
114 |
|
115 |
+
# Verificar permisos de escritura en el directorio temporal
|
116 |
+
temp_dir_writable = False
|
117 |
+
try:
|
118 |
+
test_file = os.path.join(TEMP_DIR, 'test_write.txt')
|
119 |
+
with open(test_file, 'w') as f:
|
120 |
+
f.write('test')
|
121 |
+
os.remove(test_file)
|
122 |
+
temp_dir_writable = True
|
123 |
+
except Exception as e:
|
124 |
+
logger.error(f"Error al verificar permisos de escritura en directorio temporal: {e}")
|
125 |
+
|
126 |
+
status = 'ok' if (temp_dir_exists and compiler_available and temp_dir_writable) else 'error'
|
127 |
+
|
128 |
+
response = {
|
129 |
+
'status': status,
|
130 |
'timestamp': time.time(),
|
131 |
'environment': {
|
132 |
+
'temp_dir': {
|
133 |
+
'exists': temp_dir_exists,
|
134 |
+
'writable': temp_dir_writable,
|
135 |
+
'path': TEMP_DIR
|
136 |
+
},
|
137 |
+
'compiler': {
|
138 |
+
'available': compiler_available,
|
139 |
+
'version': compiler_version
|
140 |
+
},
|
141 |
+
'python_version': os.environ.get('PYTHONVERSION', 'Unknown')
|
142 |
}
|
143 |
+
}
|
144 |
+
|
145 |
+
logger.info(f"Health check response: {response}")
|
146 |
+
return jsonify(response)
|
147 |
|
148 |
if __name__ == '__main__':
|
149 |
port = int(os.environ.get('PORT', 5000))
|
gunicorn_config.py
CHANGED
@@ -5,12 +5,12 @@ import multiprocessing
|
|
5 |
bind = "0.0.0.0:5000"
|
6 |
|
7 |
# Worker processes
|
8 |
-
workers =
|
9 |
-
worker_class = "
|
10 |
-
threads =
|
11 |
|
12 |
# Timeout settings
|
13 |
-
timeout =
|
14 |
keepalive = 2
|
15 |
|
16 |
# Server mechanics
|
|
|
5 |
bind = "0.0.0.0:5000"
|
6 |
|
7 |
# Worker processes
|
8 |
+
workers = 1
|
9 |
+
worker_class = "gthread" # Cambiado de gevent a gthread para coincidir con los logs
|
10 |
+
threads = 4
|
11 |
|
12 |
# Timeout settings
|
13 |
+
timeout = 300
|
14 |
keepalive = 2
|
15 |
|
16 |
# Server mechanics
|
huggingface.yml
CHANGED
@@ -4,4 +4,5 @@ health_check:
|
|
4 |
url: /api/health
|
5 |
interval: 10
|
6 |
timeout: 5
|
7 |
-
retries: 3
|
|
|
|
4 |
url: /api/health
|
5 |
interval: 10
|
6 |
timeout: 5
|
7 |
+
retries: 3
|
8 |
+
initial_delay: 10
|
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ flask==2.0.1
|
|
2 |
flask-cors==3.0.10
|
3 |
gunicorn==20.1.0
|
4 |
python-dotenv==0.19.0
|
5 |
-
werkzeug==2.0.1
|
|
|
|
2 |
flask-cors==3.0.10
|
3 |
gunicorn==20.1.0
|
4 |
python-dotenv==0.19.0
|
5 |
+
werkzeug==2.0.1
|
6 |
+
gevent==21.12.0
|