Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.39k stars 2.61k forks source link

logs path and name issue #5852

Open ovi-75 opened 2 months ago

ovi-75 commented 2 months ago

What's going wrong?

I have 2 apps runing on pm2 id 0 - APP0
path for this app is D:\APP\APP0

id 1 - APP1 path for this app is D:\APP\APP1

nothing fancy.

I want all logs for APP0 to go in D\APP\APP0\Logs and in D\APP\APP1\Logs for APP1 I also want the files to contain dates. like err-2024-07-03-id-0.log and out-2024-07-03-id-0.log.

My ecosystem.config look like this :

/ configuration PM2 / const moment = require('../node_modules/moment-timezone'); module.exports = { apps: [ { name: 'APP0', script: 'server.js', cwd: 'D:/APP/APP0/', args: '--env production --pathServer D:/APP/APP0/', error_file: 'D:/APP/APP0/logs/err-' + ${moment().tz('Europe/Paris').format('YYYY-MM-DD')}-id + .log, out_file: 'D:/APP/APP0/logs/out-' + ${moment().tz('Europe/Paris').format('YYYY-MM-DD')}-id + .log, combine_logs: false, time: false, logDateFormat: ${moment().tz('Europe/Paris').format('YYYY-MM-DD HH:mm:ss')}, instances: 1, exec_mode: "cluster", autorestart: true, watch: false,
max_memory_restart: '1G', env_production: { NODE_ENV: 'production', NO_DEPRECATION: 'tedious' } }] };

And at first sight, it work ! happy ! troubles come after 1 day. if i delete logs and restart, the file name stay exactly the same. the date is not updated with current date, but keep the date when i create the app.

I'm not an expert so I do certainly things not right, so all help/advice would be apreciate.

Also, i have try to change things about log files, and only way i found to change to be taken into concideration was to delete APP0 and recreate it, with mess the IDs ... if there is a way to reload everything or at least to use available id without having to kill everything, I would be happy to know too !

Thank you

fbeqirllari commented 2 months ago

restart keeps the same ecosystem definition, try to delete and start

ovi-75 commented 2 months ago

sadly delete and start increase the ID number, so the file name will be wrong

also, i can't delete and recreate things daily