xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

PM2 All In One

PM2 All In One

https://pm2.keymetrics.io/

https://pm2.io/

$ yarn global add  pm2
# OR
$ npm install pm2 -g

# global
$ pm2 start ./server.js

$ pm2 list

# pm2 stop ID
$ pm2 stop 0

$ pm2 monit

$ yarn add -D pm2
# OR
$ npm i -D pm2
# local
$ ./node_modules/pm2/bin/pm2 start ./server.js

$ ./node_modules/pm2/bin/pm2 list

# $ ./node_modules/pm2/bin/pm2 stop ID
$ ./node_modules/pm2/bin/pm2 stop 0

$ ./node_modules/pm2/bin/pm2 monit

daemon

后台守护进程

pm2 & ecosystem.config.js

https://www.npmjs.com/package/pm2

https://github.com/Unitech/pm2

docs

https://pm2.io/doc/en/runtime/quick-start/

$ yarn global add pm2

# $ pm2 [start|restart|stop|delete] ecosystem.config.js

$ pm2 start ecosystem.config.js
$ pm2 restart ecosystem.config.js
$ pm2 stop ecosystem.config.js
# $ pm2 delete ecosystem.config.js

$ yarn add -D pm2

$ ./node_modules/pm2/bin/pm2 start ecosystem.config.js
$ ./node_modules/pm2/bin/pm2 restart ecosystem.config.js
$ ./node_modules/pm2/bin/pm2 stop ecosystem.config.js
# $ ./node_modules/pm2/bin/pm2 delete ecosystem.config.js

// ecosystem.config.js
module.exports = {
  apps : [{
    name: "app",
    script: "./app.js",
    env: {
      NODE_ENV: "development",
    },
    env_production: {
      NODE_ENV: "production",
    }
  }]
}

nodemon

https://nodemon.io/

https://github.com/remy/nodemon#nodemon

https://www.npmjs.com/package/nodemon


$ yarn global add  nodemon
# OR
$ npm install -g nodemon

# global
$ nodemon ./server.js localhost 8080

$ nodemon --inspect ./server.js 80

$ yarn add -D nodemon
# OR
$ npm i -D nodemon

# local
$ ./node_modules/nodemon/bin/nodemon.js ./server.js localhost 8080

$ ./node_modules/nodemon/bin/nodemon.js --inspect ./server.js 80

# js !== cli 👎❌
# $ ./node_modules/nodemon/bin/nodemon ./src/index.js
$ ./node_modules/nodemon/bin/nodemon.js ./src/index.js

refs

https://www.cnblogs.com/xgqfrms/p/13621076.html

https://www.cnblogs.com/xgqfrms/tag/nodemon/



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-09-29 00:04  xgqfrms  阅读(113)  评论(1编辑  收藏  举报