場景: 目前在ECS中起了多個node服務,使用forever進程守護,最近,打開線上頁面發現報錯502 Bad Gateway
;同時部分靜態資源訪問不到.(之前可以的);
解決:
首先查看nginx的日志信息,基本為如下重復;
2017/04/25 22:09:45 [warn] 25037#0: *12 an upstream response is buffered to a temporary file /usr/local/nginx/proxy_temp/3/00/0000000003 while reading upstream, client: 125.119.1.1, server: channel.zhaoleilei.cn, request: “GET /build/common.js HTTP/1.1”, upstream: “http://127.0.1.1:2000/build/common.js“, host: “channel.zhaoleilei.cn”, referrer: “http://channel.zhaoleilei.cn/login”
2017/04/25 22:09:54 [info] 25037#0: *12 client prematurely closed connection while sending to client, client: 125.119.1.1, server: channel.zhaoleilei.cn, request: “GET /build/common.js HTTP/1.1”, upstream: “http://127.0.1.1:2000/build/common.js“, host: “channel.zhaoleilei.cn”, referrer: “http://channel.zhaoleilei.cn/login”
上網查找原因,未果。感覺問題出在了nginx或者forever這里;打開nginx.conf
嘗試修改配置時發現報錯E514: write error (file system full?)
;找到原因,說是磁盤滿了。查看ubuntu磁盤空間用滿的處理方法解決問題。
結論: 出現這個問題的原因在於forever的臨時log日志過大,導致磁盤滿了,刪除日志即可。
拓展: 做定時任務日志切割,以天為單位做壓縮備份(可以通過腳本實現),保留一定時間以備查看,有需要可以做日志分析。