Back to Part 0. StudyBuddy is down. Here's the calm, ordered way through it, using only this file's commands.
1. Is the service running? systemctl status studybuddy
2. What do its logs say? journalctl -u studybuddy --since "30 min ago" | tail -100
3. Is the disk full? df -h
4. What's filling it? sudo du -sh /var/log/* | sort -h | tail
5. Is memory exhausted? free -h (and: dmesg | grep -i "killed process")
6. Is the CPU overloaded? uptime · top
7. Is it listening on its port? ss -tlnp | grep 8000 (Mac: lsof -i :8000)
8. Does it answer locally? curl -v http://localhost:8000/health
9. Can it reach its dependencies? nc -vz 10.0.21.5 5432 · dig api.openai.comWhat each finding means:
| Symptom you find | Likely meaning | Next move |
|---|---|---|
status shows failed, logs end with a Python traceback | the app crashed on start (bad config, bad deploy) | read the traceback; roll back (current symlink, Ch 3) |
df -h shows / at 100% | disk full — logs or temp files grew | find the big files with du; delete/rotate old logs |
deleted a big log but df still says full | a process still has it open (Operating Systems Ch 10) | sudo lsof +L1 to find it; restart that process |
dmesg shows Out of memory: Killed process ... (uvicorn) | the OOM killer (Operating Systems Ch 5) | look for a memory leak; add memory limits and alerts |
| load average far above core count | CPU overloaded | top to find the process; scale out or fix the hot code |
| nothing listening on 8000 | the app isn't running, or bound elsewhere | check the ExecStart line and --port |
listening, but curl to localhost hangs | app stuck (blocked event loop, deadlock — Operating Systems Ch 8–11) | check logs, thread dumps; restart as a stopgap |
nc to the database times out | firewall / security group / route (Networking 2: TCP, UDP and Ports Ch 11) | check the rules on both sides |
dig fails | DNS problem (Networking 3: DNS, HTTP and HTTPS Ch 2) | check /etc/resolv.conf, the resolver |
Useful commands not covered earlier:
df -h # disk space per file system, human-readable
du -sh * # size of each item in this folder
free -h # RAM and swap use (Linux; on Mac use `vm_stat` or Activity Monitor)
uptime # how long since boot + load averages
dmesg -T | tail # kernel messages, with readable timestamps — OOM kills, disk errors
ss -tlnp # TCP sockets that are Listening, as Numbers, with the Process (Linux)
lsof -i :8000 # which process uses port 8000 (Mac and Linux)After the fire is out: write down what happened, how you found it, and what will stop it happening again (log rotation, disk alerts, memory limits). That write-up is a postmortem, and interviewers love hearing about them (Observability in Practice (coming soon)).