NODEJS(7)Nodes Live for Ever
1. Installation PM2 Tool
>sudo npm install pm2@latest -g
2. How we use pm2
Command to start multiple nodes on one machine with one port number
>PORT=3001 DEBUG="express:* monk:*" pm2 start app.js --name noderest1 -i max
-i max will be use as much CPU resource as we can
Command to start multiple nodes on one machine with one port number
>PORT=3001 DEBUG="express:* monk:*" pm2 start app.js --name noderest1 -i 4
-i 4 means will start 4 apps on this port.
Command to list all the apps running on my machine.
>pm2 list
│ App name │ id │ mode │ PID │ status │ restarted │ uptime │ memory │ watching ├─────────────┼────┼─────────┼───────┼────────┼───────────┼────────┼──────────────┼────────────│ noderest1 │ 0 │cluster│ 2167 │online│ 0 │ 7d │ 124.000 KB │unactivated│ noderest1 │ 1 │cluster│ 2168 │online│ 0 │ 7d │ 784.000 KB │unactivated│ noderest1 │ 2 │cluster│ 2169 │online│ 0 │ 7d │ 2.512 MB │unactivated││ noderest1 │ 3 │cluster│ 2174 │online│ 0 │ 7d │ 18.137 MB │unactivated│ Pm2Http9615 │ 4 │fork │ 70410 │online│ 0 │ 4d │ 1.188 MB │unactivated│└─────────────┴────┴─────────┴───────┴────────┴───────────┴────────┴──────────────┴────────────
We can only get the JSON response from the servers.
>pm2 web
We can visit http://localhost:9615/ and get all the JSON data for the processes and machine information.
Monitor all the apps
>pm2 monit
⌬ PM2 monitoring : ●noderest1 [ ] 0 % [0] [cluster_mode] [ ] 124.000 KB ●noderest1 [ ] 0 % [1] [cluster_mode] [| ] 784.000 KB ●noderest1 [ ] 0 % [2] [cluster_mode] [|||| ] 2.512 MB ●noderest1 [ ] 0 % [3] [cluster_mode] [||| ] 19.148 MB ●Pm2Http9615 [ ] 0 % [4] [fork_mode] [|| ] 1.188 MB
Show all the logs
>pm2 logs
Empty all log files
>pm2 flush
PM2 Flushing /Users/carl/.pm2/pm2.log PM2 Flushing PM2 /Users/carl/.pm2/logs/noderest1-out-0.log PM2 /Users/carl/.pm2/logs/noderest1-err-0.log PM2 Flushing PM2 /Users/carl/.pm2/logs/noderest1-out-1.log PM2 /Users/carl/.pm2/logs/noderest1-err-1.log PM2 Flushing PM2 /Users/carl/.pm2/logs/noderest1-out-2.log PM2 /Users/carl/.pm2/logs/noderest1-err-2.log PM2 Flushing PM2 /Users/carl/.pm2/logs/noderest1-out-3.log PM2 /Users/carl/.pm2/logs/noderest1-err-3.log PM2 Flushing PM2 /Users/carl/.pm2/logs/Pm2Http9615-out-4.log PM2 /Users/carl/.pm2/logs/Pm2Http9615-err-4.log
And also some other useful commands.
pm2 stop 0, pm2 delete 0, pm2 delete all, pm2 stop all, pm2 restart all,
Start One App with Name, then manage it with Name
>PORT=3001 DEBUG="express:* monk:*" pm2 start app.js --name noderest1 -i max
>pm2 restart noderest1
Processing...... PM2 Restarting process by name noderest1 PM2 Process noderest1 restarted
Reloading without downtime
>pm2 reload noderest1
Processing...... PM2 Reloading process by name noderest1 PM2 Process noderest1 succesfully reloaded PM2 Process noderest1 succesfully reloaded PM2 Process noderest1 succesfully reloaded PM2 Process noderest1 succesfully reloaded PM2 All processes reloaded
pm2 can watch current directory and restart the app when a file changes
>pm2 start app.js —watch
References:
Make the nodejs app live for ever
https://github.com/nodejitsu/forever
https://github.com/Unitech/pm2
https://github.com/Unitech/pm2#a1
- 浏览: 2567200 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 491NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 351Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 449Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 401Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 496NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 438Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 346Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 262GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 463GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 336GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 322Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 330Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 320Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 307NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 272Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 585NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 279Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 388Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 387Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
7天搞定nodejs微信公众号开发。需要学习后台开发的同学可以看看,非常不错。
用于nodejs的安装包 可直接安装 不需要其他的东西
节点S7 NodeS7 是一个库,允许使用西门子 S7 以太网协议 RFC1006 与 S7-300/400/1200/1500 PLC 进行通信。 本软件与 Siemens 没有任何关系,I 也没有。S7-300、S7-400、S7-1200 和 S7-1500 是 Siemens AG 的商标。...
nodejs初级教程
MS SQL Server Nodejs 在Windows 7 64位下的最新编译版本 Nodejs为0.10.20,msnodesql版本号为0.2.1 将上次上传的文件中不需要的中间文件清除,文件大小从8.4M缩小到502K。 安装方法:将压缩包解压到项目的node_...
nodejs14.9.0
节点js NodeJS示例项目
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者在服务器端使用JavaScript进行编程。这个"NodeJS学习笔记和代码"的压缩包显然包含了帮助初学者掌握NodeJS基础知识和实践技能的所有必要资料。 ...
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者在服务器端使用JavaScript进行编程,从而打破了JavaScript只能在浏览器中运行的传统。本"NodeJS整理手册文档"旨在为对NodeJS感兴趣的朋友们提供一...
nodejs11安装文件,解决win7操作系统nodeJs环境搭建失败问题:Node.js is only supported on Windows 8.1, Windows Server 2012 R2, or higher
NodeJS是基于Web网络应用的富客户端JavaScript,它使得浏览器直接的通讯更加方便与强大
2013年7月4日制作的nodejs官网的最新版本的chm文档,方便nodejs学习者离线预览nodejs官网,包括nodejs的英文api
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者使用JavaScript进行服务器端编程,打破了JavaScript只能在浏览器中运行的传统。本指南将深入探讨NodeJS的核心概念、开发工具、模块系统、网络编程...
基于nodejs的西餐外卖系统和微信小程序源码基于nodejs的西餐外卖系统和微信小程序源码基于nodejs的西餐外卖系统和微信小程序源码基于nodejs的西餐外卖系统和微信小程序源码基于nodejs的西餐外卖系统和微信小程序源码...
资源名称:NodeJs技术经典文档资源目录:【】Node.js开发指南_中文正版【】nodejs开发指南pdf及源码及win安装程序【】nodejs手册中文【】NodeJs教程【】umav4simple【】七天学会NodeJS【】七天学会NodeJS【】深入浅...
nodeJs 12.22.12-x64-windows版本 nodeJs 12.22.12-x64-windows版本 nodeJs 12.22.12-x64-windows版本 nodeJs 12.22.12-x64-windows版本 nodeJs 12.22.12-x64-windows版本
NodeJS 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,它让开发者能够在服务器端使用 JavaScript 进行编程,极大地推动了全栈开发的流行。NodeJS 的设计思想是事件驱动、非阻塞 I/O 模型,这使得它在处理高并发...
nodejs 学习笔记 nodejs 学习笔记 nodejs 学习笔记
Idea 配置前端 Web Nodejs 项目 Idea 配置前端 Web Nodejs 项目是指在 IntelliJ IDEA 集成开发环境中配置 Nodejs 项目的步骤。下面我们将详细讲解配置的步骤和相关知识点。 Idea 配置 Nodejs 项目 首先,我们需要...
NodeJS 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,它允许开发者在服务器端使用 JavaScript 进行编程,极大地提升了开发效率。在 Windows 环境下配置和使用 NodeJS,主要涉及以下几个步骤: 一、安装 ...