nodejs的一些玩法

node的一些玩法

怎么稳定的部署node.js项目

npm install pm2 -g 

pm2可以完全掌控程序的生命周期,创建,删除,查看等。

pm2 start app.js 开启一个应用进程

http://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/

一个常见的需求时,在进程崩溃或者系统重启后,我的应用进程可以自动唤起。
pm2是生产级别的进程管理工具,它完全可以实现上述需求,当然不是它本身实现的,而是借住了操作系统的能力。不同的操作系统具体方法不同,不过pm2做了一层封装,很容易使用

systemd: Ubuntu >= 16, CentOS >= 7, Arch, Debian >= 7
upstart: Ubuntu <= 14
launchd: Darwin, MacOSx
openrc: Gentoo Linux, Arch Linux
rcd: FreeBSD
systemv: Centos 6, Amazon Linux
These init systems are automatically detected by PM2 with the pm2 startup command
posted @ 2022-03-06 10:38  叶常落  阅读(20)  评论(0编辑  收藏  举报