ancerlop commited on
Commit
51b0147
verified
1 Parent(s): 1abd012

Fix Error not start

Browse files
Files changed (5) hide show
  1. README.md +1 -1
  2. app.py +34 -7
  3. gunicorn_config.py +4 -4
  4. huggingface.yml +2 -1
  5. requirements.txt +2 -1
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: 42CodeRunner Backend
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
- 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))
 
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 = 2
9
- worker_class = "sync"
10
- threads = 2
11
 
12
  # Timeout settings
13
- timeout = 120
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