Spaces:
Sleeping
Sleeping
adding files
Browse files
main.py
CHANGED
@@ -156,25 +156,29 @@ def internal_server_error_handler(exc):
|
|
156 |
log_dir = '/home/user/logs' # Update to a directory inside user's home directory
|
157 |
if not os.path.exists(log_dir):
|
158 |
os.makedirs(log_dir, exist_ok=True)
|
|
|
|
|
|
|
159 |
|
160 |
# Configure basic logging
|
161 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
162 |
|
163 |
# Debugging: log environment variables
|
164 |
-
logging.info(f"PORT: {os.getenv('PORT')}")
|
165 |
-
logging.info(f"THREADS: {os.getenv('THREADS')}")
|
166 |
-
logging.info(f"CONNECTION_LIMIT: {os.getenv('CONNECTION_LIMIT')}")
|
167 |
-
logging.info(f"CHANNEL_TIMEOUT: {os.getenv('CHANNEL_TIMEOUT')}")
|
168 |
|
169 |
-
# Use
|
170 |
if __name__ == "__main__":
|
171 |
try:
|
172 |
-
#
|
173 |
-
logging.info("Starting
|
174 |
-
|
175 |
-
|
|
|
176 |
except Exception as e:
|
177 |
-
logging.error(f"Error starting
|
178 |
raise
|
179 |
|
180 |
|
@@ -184,3 +188,4 @@ if __name__ == "__main__":
|
|
184 |
|
185 |
|
186 |
|
|
|
|
156 |
log_dir = '/home/user/logs' # Update to a directory inside user's home directory
|
157 |
if not os.path.exists(log_dir):
|
158 |
os.makedirs(log_dir, exist_ok=True)
|
159 |
+
logging.info(f"Created log directory at: {log_dir}")
|
160 |
+
else:
|
161 |
+
logging.info(f"Log directory already exists: {log_dir}")
|
162 |
|
163 |
# Configure basic logging
|
164 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
165 |
|
166 |
# Debugging: log environment variables
|
167 |
+
logging.info(f"PORT: {os.getenv('PORT', 'Not Set')}")
|
168 |
+
logging.info(f"THREADS: {os.getenv('THREADS', 'Not Set')}")
|
169 |
+
logging.info(f"CONNECTION_LIMIT: {os.getenv('CONNECTION_LIMIT', 'Not Set')}")
|
170 |
+
logging.info(f"CHANNEL_TIMEOUT: {os.getenv('CHANNEL_TIMEOUT', 'Not Set')}")
|
171 |
|
172 |
+
# Use Flask development server for Hugging Face Spaces compatibility (instead of Waitress)
|
173 |
if __name__ == "__main__":
|
174 |
try:
|
175 |
+
# Log the server startup info
|
176 |
+
logging.info("Starting Flask application...")
|
177 |
+
|
178 |
+
# Start the Flask application with the development server for testing
|
179 |
+
app1.run(host="0.0.0.0", port=int(os.getenv("PORT", 7860)), threaded=True)
|
180 |
except Exception as e:
|
181 |
+
logging.error(f"Error starting Flask application: {e}")
|
182 |
raise
|
183 |
|
184 |
|
|
|
188 |
|
189 |
|
190 |
|
191 |
+
|