Spaces:
Sleeping
Sleeping
start setup
Browse files
app.py
CHANGED
|
@@ -163,39 +163,6 @@ def upload_state(p: StatePayload):
|
|
| 163 |
except Exception as e:
|
| 164 |
raise HTTPException(500, f"upload_state failed: {e}")
|
| 165 |
|
| 166 |
-
@app.on_event("startup")
|
| 167 |
-
async def startup_event():
|
| 168 |
-
"""μλ² μμ μ μ΄κΈ°ν"""
|
| 169 |
-
print("π MuscleCare API μλ² μμ μ€...")
|
| 170 |
-
|
| 171 |
-
# λ‘κ·Έ λλ ν 리 μμ± (λ‘컬/λ°°ν¬ νκ²½ ꡬλΆ)
|
| 172 |
-
log_dir = "/app/logs" if os.path.exists("/app") else "./logs"
|
| 173 |
-
os.makedirs(log_dir, exist_ok=True)
|
| 174 |
-
print(f"π λ‘κ·Έ λλ ν 리 μμ±: {log_dir}")
|
| 175 |
-
|
| 176 |
-
# Oracle DB μ΄κΈ°ν
|
| 177 |
-
try:
|
| 178 |
-
db_initialized = init_db_from_env()
|
| 179 |
-
if db_initialized:
|
| 180 |
-
print("β
Oracle DB μ°κ²° μλ£")
|
| 181 |
-
else:
|
| 182 |
-
print("β οΈ Oracle DB μ°κ²° μ€ν¨ - DB κ΄λ ¨ κΈ°λ₯μ΄ λΉνμ±νλ©λλ€")
|
| 183 |
-
except Exception as e:
|
| 184 |
-
print(f"β Oracle DB μ΄κΈ°ν μ€λ₯: {e}")
|
| 185 |
-
|
| 186 |
-
print("β
μλ² μμ μλ£")
|
| 187 |
-
|
| 188 |
-
@app.on_event("shutdown")
|
| 189 |
-
async def shutdown_event():
|
| 190 |
-
"""μλ² μ’
λ£ μ μ 리"""
|
| 191 |
-
print("π μλ² μ’
λ£ μ€...")
|
| 192 |
-
try:
|
| 193 |
-
db_manager = get_db_manager()
|
| 194 |
-
db_manager.close()
|
| 195 |
-
print("β
Oracle DB μ°κ²° μ’
λ£ μλ£")
|
| 196 |
-
except Exception as e:
|
| 197 |
-
print(f"β μ’
λ£ μ²λ¦¬ μ€λ₯: {e}")
|
| 198 |
-
|
| 199 |
|
| 200 |
@app.get("/user_dataset/{user_id}")
|
| 201 |
async def read_user_dataset(user_id: str):
|
|
|
|
| 163 |
except Exception as e:
|
| 164 |
raise HTTPException(500, f"upload_state failed: {e}")
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
@app.get("/user_dataset/{user_id}")
|
| 168 |
async def read_user_dataset(user_id: str):
|