[Server Running] [Node.js, PM2] Using PM2 To Keep Your Node Apps Alive
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.
Install:
- $ npm install pm2 -g
Before Start:
PM2 can generate and configure a startup script to keep PM2 and your processes alive at every server restart.
- $ pm2 startup
- # auto-detect platform
- $ pm2 startup [platform]
- # render startup-script for a specific platform, the [platform] could be one of:
- # ubuntu|centos|redhat|gentoo|systemd|darwin|amazon
Start:
- $ pm2 start bin/www /* meds example */
This has the same effect as:
$ node bin/www
run the app, but on windows, it just keep it run once, once you refresh the page, the app die. [PROBLEM]
If it works as expected, when you kill the process:
- kill - <pid>
The pm2 will detect that our app is crashed, so it will start a new pid to run the app.
[Notice:] On Linux, PM2 will grap the root, run as root, but in genral, we don't want to use root. So we usually create a user to use PM2.
pm2 startup on liunx:
Change the user:
test script:
More information:
https://egghead.io/lessons/node-js-using-pm2-to-keep-your-node-apps-alive
https://github.com/Unitech/pm2
[Server Running] [Node.js, PM2] Using PM2 To Keep Your Node Apps Alive的更多相关文章
- The Node.js Event Loop, Timers, and process.nextTick() Node.js事件循环,定时器和process.nextTick()
个人翻译 原文:https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/ The Node.js Event Loop, Ti ...
- 深入浅出Node.js(一):什么是Node.js
Node.js从2009年诞生至今,已经发展了两年有余,其成长的速度有目共睹.从在github的访问量超过Rails,到去年底Node.jsS创始人Ryan Dalh加盟Joyent获得企业资助,再到 ...
- 深入浅出Node.js(一):什么是Node.js(转贴)
以下内容转自:http://www.infoq.com/cn/articles/what-is-nodejs/ 作者:崔康 [编者按]:Node.js从2009年诞生至今,已经发展了两年有余,其成长的 ...
- Node.js学习笔记(1):Node.js快速开始
Node.js学习笔记(1):Node.js快速开始 Node.js的安装 下载 官方网址:https://nodejs.org/en/ 说明: 在Windows上安装时务必选择全部组件,包括勾选Ad ...
- node.js系列(实例):原生node.js+formidable模块实现简单的文件上传
/** * 原生node.js结合formidable模块实现图片上传改名 * @Author:Ghost * @Date:2016/07/15 * @description: * 1.引入模块htt ...
- node.js系列(实例):原生node.js实现接收前台post请求提交数据
前台界面: 前台代码: <form class="form-horizontal" method="post" action="http:127 ...
- node.js零基础详细教程(4):node.js事件机制、node异步IO操作
第四章 建议学习时间3小时 课程共10章 学习方式:详细阅读,并手动实现相关代码 学习目标:此教程将教会大家 安装Node.搭建服务器.express.mysql.mongodb.编写后台业务逻辑. ...
- node.js零基础详细教程(7):node.js操作mongodb,及操作方法的封装
第七章 建议学习时间4小时 课程共10章 学习方式:详细阅读,并手动实现相关代码 学习目标:此教程将教会大家 安装Node.搭建服务器.express.mysql.mongodb.编写后台业务逻辑. ...
- Node.js实战项目学习系列(1) 初识Node.js
前言 一直想好好学习node.js都是半途而废的状态,这次沉下心来,想好好的学习下node.js.打算写一个系列的文章大概10几篇文章,会一直以实际案例作为贯穿的学习. 什么是node Node.js ...
- 【Nodejs】【node.js 安装 和 配置Sublime Text的Node.js】
[一] [安装nodejs] 第一步:下载安装文件: https://nodejs.org/en/download/ 第二步:安装nodejs 下载完成之后,双击"node-v6.10.1- ...
随机推荐
- CodeForces Round #290 Div.2
A. Fox And Snake 代码可能有点挫,但能够快速A掉就够了. #include <cstdio> int main() { //freopen("in.txt&quo ...
- I.MX6 PMU MMPF0100 driver porting
/************************************************************************** * I.MX6 MMPF0100 driver ...
- RPi 2B apache2 mysql php5 and vsftp
/************************************************************************* * RPi 2B apache2 mysql ph ...
- 新功能:Azure 负载平衡器的空闲超时现可配置了
Yves Pitsch Azure 网络首席项目经理 我们很高兴地宣布,Azure负载平衡器现在可以为云服务和虚拟机提供可配置的 TCP空闲超时支持.要配置此功能,可以使用服务管理 API.Power ...
- Java [leetcode 22]Generate Parentheses
题目描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed par ...
- 【转】photoshop CS2安装激活破解教程
原文网址:http://www.16xx8.com/photoshop/jiaocheng/109348_all.html photoshop CS2安装教程:(本页介绍如何安装CS2软件,如果你安装 ...
- 在win2008中配置ServU
因为08的防火墙要求比较高.很多端口都关闭,所以要设置防火墙. 首先设置入站规则 1.新建一条规则,规则类型选择“端口”,然后TCP,设置为20-21,60010-60020,然后允许链接,在配置文件 ...
- 在SharePoint 2010中创建网站的权限级别
转:http://www.360sps.com/Item/CreatePermissionLevels.aspx 权限级别是SharePoint 2010新增加的功能,使我们对权限的设置又提高了一个层 ...
- ASCII编码:Linux&Windows
我们的服务器为linux系统,日志中的字段通常会用不同分隔符来做分隔,在不同操作系统编码格式下查看也会有不同的体现,甚至会出现所谓的乱码.我在xshell5下常用的编码格式Unicode(UTF-8) ...
- Hadoop2.7.2安装笔记
1.设置免密SSH登录 $ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/autho ...