Reputation: 234
I have to run a process with PM2 on a device with very limited disk space, so I need to disable all logging otherwise the device will run out of space after several days.
I'm using:
"out_file": "/dev/null",
"error_file": "/dev/null"
It stops PM2 from creating logs for the process. However, PM2 still creates another log file in .pm2/pm2.log
The size of pm2.log can grow up to 9Mb, which is large for the device. Is there any way to stop PM2 from creating pm2.log? Or at least some way to clean the log file automatically.
Upvotes: 3
Views: 2506
Reputation: 234
I open an issue at https://github.com/Unitech/pm2/issues/2921
Turns out that pm2.log
cannot be disabled in current version of PM2(2.4.6), but the maintainer of PM2 said that this feature will be added in future update.
For now, I'm using the following code to clean log files:
var cmd_flush ='pm2 flush';
var exec = require('child_process').exec;
exec(cmd_flush ,function(error){
debugLog('error: ' + error);
});
It's slow, but at least it works.
Upvotes: 1