圖書館debug紀錄

問題:在沒有儲存空間時嘗試上傳圖書,變相寫入了空白json文件導致以下報錯

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /root/little-library/routes/get_home.js:23:29
    at Array.map (<anonymous>)
    at /root/little-library/routes/get_home.js:22:23
    at Layer.handle [as handle_request] (/root/little-library/node_modules/express/lib/router/layer.js:95:5)
    at next (/root/little-library/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/root/little-library/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/root/little-library/node_modules/express/lib/router/layer.js:95:5)
    at /root/little-library/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/root/little-library/node_modules/express/lib/router/index.js:335:12)

1. 釋出空間

登入服務器查看儲存空間

df -h
/dev/vda1       9.4G  9.4G     0 100% /

找出佔空間的log並將其移除

sudo du -h /var/log

1.1G	/var/log/journal
1.3G	/var/log
root@vultr:~# rm -r /var/log/journal
root@vultr:~# rm -r /var/log

Usage of /: 72.4% of 9.32GB


2. 刪除空白json文件

文件路徑在 /little-library/public/files

xxx.epub xxx.json xxx.json xxx.pdf

逐一查看哪個空白,然後 rm xxx.json

回到 /little-library 重啟應用

npm start

> little-library@0.1.0 start
> node server.js

Started server on port 3000
Started SSL server on port 443

檢查沒有報錯後按Ctrl+C退出,然後執行命令 forever start