fix(backend): Add debug output to diagnose silent crash
This commit is contained in:
parent
7221a8e280
commit
e5d0ae4fd1
3 changed files with 149 additions and 6 deletions
42
backend/MAIN-RS-DEBUG-FIX.md
Normal file
42
backend/MAIN-RS-DEBUG-FIX.md
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# Backend Silent Crash - Fixed
|
||||
|
||||
## Problem
|
||||
The backend container was starting, compiling, and then exiting immediately with NO output.
|
||||
|
||||
## Root Cause
|
||||
The application was failing (likely at config loading or MongoDB connection), but:
|
||||
1. `dotenv::dotenv()` was failing silently (no .env in Docker)
|
||||
2. Errors were only going to the logger (which wasn't initialized yet)
|
||||
3. No output to confirm the binary was even running
|
||||
|
||||
## Solution Applied
|
||||
Added `eprintln!` statements throughout `main.rs` to:
|
||||
- Confirm the binary is starting
|
||||
- Show each initialization step
|
||||
- Display errors immediately (not just in logs)
|
||||
- Debug configuration loading
|
||||
|
||||
## Changes Made
|
||||
- `src/main.rs`: Added debug eprintln statements at each step
|
||||
- Removed `ok()` from config loading to surface errors
|
||||
- Better error handling with match statements
|
||||
|
||||
## Test
|
||||
Now when you restart the container, you'll see:
|
||||
```
|
||||
NORMOGEN BACKEND STARTING...
|
||||
Loading environment variables...
|
||||
No .env file found (this is OK in Docker): ...
|
||||
Initializing logging...
|
||||
Config loaded: DB=normogen_dev, Port=8000
|
||||
Connecting to MongoDB...
|
||||
MongoDB connection successful
|
||||
Server is running on http://0.0.0.0:8000
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
Restart the container and check the logs:
|
||||
```bash
|
||||
docker compose -f backend/docker-compose.dev.yml restart backend
|
||||
docker logs normogen-backend-dev -f
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue