pm2

pm2
advanced, production process manager for node.js

install

npm install pm2@latest -g

config file: ecosystem.config.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = {
apps : [{
name : "prj-name",
script : "./node_modules/vite/bin/vite.js", // vue3+vite
// script : "./bin/www", // node+express
watch: true,
ignore_watch: ["node_modules","public"],
env: {
NODE_ENV: "development",
PORT: 3000
},
log_date_format: "YYYY-MM-DD HH:mm Z"
}]
}

CheatSheet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pm2 start
pm2 log
pm2 list
pm2 describe 0

pm2 stop 0
pm2 stop all
pm2 restart 0
pm2 restart all
pm2 reload all
pm2 delete 0
pm2 delete all

pm2 save
pm2 resurrect