[Whole Web, Node.js, PM2] Configuring PM2 for Node applications
2023-09-14 08:59:21 时间
In this lesson, you will learn how to configure node apps using pm2 and a json config file.
Let's say there are tow node apps: app1, app2.
What we want to do is create a json fie as config file for pm2.
pm2.config.json:
{ "apps": [{ "name": "App1", "script": "app1/server.js" },{ "name": "App2", "script": "app2/server.js" }] }
app1/server.js:
var http = require("http"); var server = http.createServer(function(request, response){ response.writeHead('200', {"Content-Type": "text/plain"}); response.end("Hello from app1"); }); server.listen(3000); console.log("Listen on port 3000");
app2/server.js:
var http = require("http"); var server = http.createServer(function(request, response){ response.writeHead('200', {"Content-Type": "text/plain"}); response.end("Hello from app2"); }); server.listen(3001); console.log("Listen on port 3001");
Usage:
pm2 start pm2.comfing.json
相关文章
- Node.js学习笔记(三)——Node.js开发Web后台服务
- Node.js基础
- Node.js抓取网站,GBK,GB2312中文乱码解决办法
- Node.js 应用高 CPU 占用率的分析方法
- node.js常用npm命令
- 2021了,真的不要再说 Node.js 是一门编程语言了「建议收藏」
- 【说站】js中Array.of的使用
- windows 环境下使用 Node.js 访问 SAP OData 遇到 unable to get local issuer certificate
- js / css 设置div不可点击
- js根据经纬度计算距离
- js将时间戳转化为年月日时分秒_时间戳转换成日期
- JS逆向加密解密工具Crypto Magician、乐易助手、WT-JS 下载使用
- js 数组去除重复数据-当WPS开始像支持VBA一样支持JS语言时,微软又该何去何从?
- 【JS 逆向百例】猿人学系列 web 比赛第二题:js 混淆 - 动态 cookie,详细剖析
- 解除 Linux 上的 Node.js 安装(linux卸载node)
- 数据Node.js实现MySQL数据的同步更新(node同步mysql)
- node.js与neo4j构建扩展性Web应用(nodeneo4j)
- express使用Node.js、MongoDB和Express快速构建Web应用(nodemongodb)
- 利用Node.js实现对MS SQL服务器的连接(node连MSsql)
- 数据JS技术实现实时获取Oracle数据(js实时获取oracle)
- js用于树型结构级联选择
- js点击更换背景颜色或图片的实例代码
- ASP.NET中为TextBox中添加calendar.js示例代码
- JS的document.all函数使用示例
- node.js入门教程
- node.js中watch机制详解
- node.js使用npm安装插件时提示installError:ENOENT报错的解决方法
- node.js中的buffer.length方法使用说明
- node.js中的fs.fstatSync方法使用说明
- 了不起的node.js读书笔记之node的学习总结
- Node.js中使用计时器定时执行函数详解