PM2
PM2 is a daemon process manager that will help you manage and keep your application online 24/7.
Installation
npm install pm2@latest -g
Starting
pm2 start app.js
Monitoring
pm2 monit
Microservice
list all processes:
pm2 list
display logs:
pm2 logs
Act on them:
pm2 stop [app_name | all]
pm2 restart [app_name | all]
pm2 delete [app_name | all]
Troubleshooting
If the ‘stop’ or ‘delete’ commands do not work, execute the following command.
pm2 reload [app_name | all]
Ecosystem File
module.exports = {
apps: [
{
name: 'sinpro-dev',
script: 'build',
interpreter: 'node',
interpreterArgs: '--loader tsx',
instances: '-1',
exec_mode: 'cluster',
watch: false,
ignore_watch: ['logs'],
env: {
PORT: 3001,
},
},
],
}
module.exports = {
apps: [
{
name: 'talk',
script: './server/index.ts',
interpreter: 'node',
interpreterArgs: '--loader tsx',
instances: '-1',
exec_mode: 'cluster',
watch: false,
ignore_watch: ['logs'],
env: {
PORT: 3002,
},
},
],
}
Start it easily:
pm2 start ecosystem.config.cjs