pm2 工具来管理 node 服务端

2023-04-27,,

如下:

nodeServer.js

'use strict';
const http = require('http'); const server = http.createServer(function (req, res) {
res.writeHead(, {'Content-Type': 'text/html'});
res.end('Hello World\n');
}); const port = ;
server.listen(port); console.log(`Server is running at http://127.0.0.1:${port}/`);
node nodeServer

下面用pm2管理,及常用

pm2 start nodeServer.js // 启动管理

pm2 list // 或者 pm2 l 简写 // 查看所用已启动项目

pm2 restart xxx // 重启

pm2 stop xxx // 停止

pm2 delete xxx // 删除

当然也可配置json文件,来启用管理

PM2 文档: http://pm2.keymetrics.io/docs/usage/quick-start/#usage

pm2 工具来管理 node 服务端的相关教程结束。

《pm2 工具来管理 node 服务端.doc》

下载本文的Word格式文档,以方便收藏与打印。