報錯如下:
xxxx/.venv/bin/python -m uvicorn main:app --reload --proxy-headers --forwarded-allow-ips='*'
INFO: Will watch for changes in these directories: ['xxxxx路徑']
ERROR: [Errno 48] Address already in use
一條命令殺死佔用某某耑口的指令
lsof -i :程序佔用的耑口號 | awk 'NR==2 {print $2}' | xargs kill -9
因爲pycharm會默認使用8000作爲uvicorn的測試耑口, 所以實際命令是這樣的:
lsof -i :8000 | awk 'NR==2 {print $2}' | xargs kill -9