node-linux icon indicating copy to clipboard operation
node-linux copied to clipboard

wrapper.js crashes when /var/log runs out of space

Open RazZziel opened this issue 10 years ago • 1 comments

My program crashed when launched from a /etc/init.d/ script created by node-linux

This is the error, from /var/log/parkberry-error.log:

Wed Apr 01 2015 15:44:17 GMT+0200 (CEST) - SVCMGR - Uncaught exception: Error: ENOSPC, no space left on device
    at Object.fs.writeSync (fs.js:540:18)
    at Object.fs.writeFileSync (fs.js:987:21)
    at Object.fs.appendFileSync (fs.js:1024:6)
    at Socket.<anonymous> (/home/pi/node_modules/package/node_modules/node-linux/lib/wrapper.js:155:8)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:765:14)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:427:10)
    at emitReadable (_stream_readable.js:423:5)
    at readableAddChunk (_stream_readable.js:166:9)

Indeed, /var/log is full, and my program is to blame, but if node-linux is in charge of creating the log, it should be in charge or splitting/rotating it

pi@0000000023593fb2 /var/log $ df -h
Filesystem      Size  Used Avail Use% Mounted on
(...)
tmpfs           100M  100M     0 100% /var/log
(...)

pi@0000000023593fb2 /var/log $ du -sh parkberry.log 
100M    parkberry.log

RazZziel avatar Apr 01 '15 18:04 RazZziel

For now I've workarounded the problem with logrotate, creating a /etc/logrotate.d/parkberry that reads:

/var/log/parkberry.log {
  rotate 4
  size 10M
  compress
  missingok
  notifempty
}

(still untested, but should be fine)

This way I make sure I never have more than 40M in logs (at least for this app), so wrapper.js shouldn't crash (unless /var/log gets full by some other app)

RazZziel avatar Apr 02 '15 09:04 RazZziel