I'm using PM2 to manage my node js application. Here i want to configure custom log path which is unique to the server/node that pm2 is running
module.exports = {
apps : [{
name: 'nodeapp-dev',
script: 'src/index.js',
instances: 1,
exec_mode: 'fork',
autorestart: true,
watch: false,
max_memory_restart: '512M',
error_file: '/home/user/.pm2/logs/$HOSTNAME/nodeapp-dev-error.log',
out_file: '/home/user/.pm2/logs/$HOSTNAME/nodeapp-dev-out.log',
env: {
NODE_ENV: 'dev'
}
}]
}
I want to write the log files to folder created by sever hostname and this should be work on a other server as well. could you help me to achieve this as $HOSTNAME didn't work for me. it just created folder "$HOSTNAME". But in in linux systems has the env variable for $HOSTNAME
PM2 show output
| error log path │ /home/user/.pm2/logs/$HOSTNAME/nodeapp-dev-error.log │
│ out log path │ /home/user/.pm2/logs/$HOSTNAME/nodeapp-dev-out.log