PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
PM2是一个用于Node.js应用的进程管理器,带有内置的负载均衡器。它允许您使应用程序永远存活,在不停机的情况下重新加载它们,并简化常见的系统管理任务。
1、 全局下载pm2
npm install pm2 -g
2、之前启动node项目用的命令为
npm run dev
修改为
pm2 start npm -- run dev
启动成功会出现如下效果图
语法:pm2 start npm --watch
pm2 start npm --name <taskname>
pm2 start npm -- run <scriptname>
停止pm2
pm2 stop npm