Search code examples
javascriptforever

Clean up log files for failed Forever.js tasks


When trying to start a process using Forever.js and it fails, the process continues to appear in the forever list output as stopped. In this screenshot, this the case with all 4 stopped processes:

enter image description here

What's the right way to remove those? Should I use the cleanlogs command? What if I want to preserve the log files but just remove those processes from the output of forever list?


Solution

  • Base on my tests, it looks like this is the rule:

    • If a task exit on exception, it will be marked as "STOPPED" and kept in forever list.
    • You can use forever stop xxx to remove a STOPPED task from forever list.
    • With forever stop xxx, the corresponding log will be cleared too. So if you want to keep the error log, move it somewhere else before forever stop xxx.