avatarkava / beavisbot

A node.js powered bot for plug.dj and dubtrack.fm
https://github.com/avatarkava/beavisbot/wiki
MIT License
22 stars 20 forks source link

Add logging with rotation #51

Closed avatarkava closed 10 years ago

avatarkava commented 10 years ago

See similar implementation on another fork here: https://github.com/audaxion/drone/commit/459ea127ac361e91e761bc9407588c89945b0840

omfgitsasalmon commented 10 years ago

@AvatarKava Yes I am aware of that. Is the bot operational now?

I would like to implement this bot together with a website that offers statistics and show what song is overplayed etc. Would be great if you can offer mySQL support. Easier for me to pull data too!

Btw, I also wanted to ask if you're interested to set up a slack account and we can all discuss about the development of this bot.

avatarkava commented 10 years ago

Semi-operational. He'll be able to connect, but code changes are still needed to get all the functionality working. I've removed the rest of the comments here since they're not applicable to the ticket and will comment on the slack account in that ticket when I get a moment.

avatarkava commented 10 years ago

the two big candidates for logging seem to be winston (https://github.com/flatiron/winston) and bunyan (https://github.com/trentm/node-bunyan)

avatarkava commented 10 years ago

Since we're using pm2 it probably isn't necessary to use winston or bunyan, actually...

http://www.z-car.com/blog/programming/how-to-rotate-logs-using-pm2-process-manager-for-node-js

avatarkava commented 10 years ago

Think this one's outside of the scope of the bot - I say we recommend using pm2 and then rotating the logs using logrotate. Comment if there's disagreement here - I'm open to discussion but this was easy to set up and probably is a better solution than trying to build in something to the bot.

Full details are here: https://github.com/Unitech/pm2

Start the process in pm2 with custom log locations:

pm2 start /srv/web/apps/plug.dj/BeavisBot/bot.js --name beavisbot -o /var/log/node/beavisbot.log -e /var/log/node/beavisbot.err

Set pm2 to automatically run on startup

pm2 startup <ubuntu|centos|gentoo|systemd>

Save the processes running so they get restored any time pm2 is started

pm2 save

then in /etc/logrotate.d

/var/log/node/* {
    daily
    rotate 30
    missingok
    notifempty
    sharedscripts
    copytruncate
    compress
    delaycompress
    dateext
}