Search code examples
linuxnode.jsubuntuforeverlogrotate

Switch forever logs without stopping forever service


We are using forever in our production environment and when trying to rotate the logs my forever process is killed even though I'm using copytruncate. Now, I can bypass this by restarting the forever service in my postrotate scripts, but I wanted to know whether there is a command to change to forever log file. Something like - forever restart -l new_log.log app.js

Is there any way to do something like this? or is stopping and starting the forever process an absolute neccesity?

Thanks a bunch.


Solution

  • Yes, stopping and restarting is necessary. I'd definitely recommend using pm2 instead. It offers the same as forever and much much more. It's also a lot easier to use. And it has a log-rotate plugin which automatically takes care of log rotation, completely hassle-free and fully configured as you want.