[Whole Web, Node.js, PM2] Configuring PM2 for Node applications
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

[Whole Web, Node.js, PM2] Configuring PM2 for Node applications的更多相关文章
- [Node.js] 01 - How to learn node.js
基本概念 链接:https://www.zhihu.com/question/47244505/answer/105026648 链接:How to decide when to use Node.j ...
- node.js day01学习笔记:认识node.js
Node.js(JavaScript,everywhere) 1.Node.js 介绍 1.1. 为什么要学习Node.js 企业需求 + 具有服务端开发经验更好 + front-end + back ...
- node.js学习(二)--Node.js控制台(REPL)&&Node.js的基础和语法
1.1.2 Node.js控制台(REPL) Node.js也有自己的虚拟的运行环境:REPL. 我们可以使用它来执行任何的Node.js或者javascript代码.还可以引入模块和使用文件系统. ...
- Node.js学习笔记(五) --- 使用Node.js搭建Web服务器
1. Node.js 创建的第一个应用 1.引入http模块 var http = require("http"); 2. 创建服务器接下来我们使用 http.createServ ...
- Node.js 学习(五)Node.js 事件循环
Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高. Node.js 的每一个 API 都是异步的,并作为一个独立线程运行,使用异步函数调用,并处理并发. Node.j ...
- [Node.js] Add Logging to a Node.js Application using Winston
Winston is a popular logging library for NodeJS which allows you to customise the output, as well as ...
- 创业笔记-Node.js入门之JavaScript与Node.js
JavaScript与Node.js JavaScript与你 抛开技术,我们先来聊聊你以及你和JavaScript的关系.本章的主要目的是想让你看看,对你而言是否有必要继续阅读后续章节的内容. 如果 ...
- 前端(Node.js)(3)-- Node.js实战项目开发:“技术问答”
1.Web 与 Node.js 相关技术介绍 1.1.Web应用的基本组件 web应用的三大部分 brower(GUI)<==>webserver(business logic.data ...
- 前端(Node.js)(2)-- Node.js开发环境配置
1.开发环境介绍 1.MEAN Stack 什么是全栈? 负责界面和UI的设计师.负责移动端应用开发的安卓IOS开发工程师.负责服务器端开发的后端程序员.负责数据库开发和管理的数据库工程师.负责服务器 ...
随机推荐
- [Gauss]POJ1830 开关问题
中文题 题意不多说 这题乍一看 就是求个自由未知量个数 相当简单 其实呢 其中要注意的细节还是很多的: 1.光求了自由未知量个数 还不够 ∵求的是可行方案的总数 因此 答案是 2^(自由未知量个数) ...
- 调试Android USB遇到的令人费解的问题
上周参照网上代码,做了USB的初步探测程序,工作正常 .今天从硬件部拿到了一段例程,原本打算参考它来完善自己的程序.但运行之后总是报错,逐步跟进错误,进而发现了一个匪疑所思的问题.调试一天也未发现原因 ...
- 上海CEC大收购(包括华大九天)
紫光收购展讯.锐迪科后,上海开始通过扶植CEC培育新势力,CEC已经收购上海澜起,即将收购amlogic.Ominivision,还在与marvell眉来眼去,此外华大九天已经移植上海,加上之前的上海 ...
- Structs 原理图
Struts开源架构很好的实现了MVC模式,MVC即Model-View-Controller的缩写,是一种常用的设计模式.MVC 减弱了业务逻辑接口和数据接口之间的耦合,以及让视图层更富于变化.MV ...
- Linq中的常用方法
System.Linq System.Linq.Enumerable 类 Range Repeat Reverse Select Where Sum Zip Aggregate Count Firs ...
- String对象不可改变的特性
1. 声明String对象 String s = "abcd"; 图1 2. 将一个字符串变量赋值给另一个String变量 String s2 = s; 图2 3. 字符串连接 s ...
- NOI2014 动物园
3670: [Noi2014]动物园 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 174 Solved: 92[Submit][Status] D ...
- Guid 的几种形式
Guid.NewGuid().ToString()得几种格式显示 1.Guid.NewGuid().ToString("N") 结果为: 38bddf48f43c485 ...
- SharePoint 2010 master page 控件介绍(2):ribbon (一同事读听着像泪奔)
转:http://blog.csdn.net/lgm97/article/details/6409208 <!-- ===== 开始Ribbon ======================= ...
- 处理Selection对象和Range对象——Word VBA中重要的两个对象
处理Selection对象和Range对象——Word VBA中重要的两个对象 Word 开发人员参考Selection 对象代表窗口或窗格中的当前所选内容.所选内容代表文档中选定(或突出显示)的区域 ...