Node.js 学习(七)Node项目部署工具之forever
平常无论是使用命令行还是终端通过node app.js启动项目时,当命令行或终端关闭时项目也就随之关闭了;
forever则可以在cmd或ssh连接断开时,让项目一直运行,而且可以在项目崩溃时自动重启
安装forever,forever是npm中的一个包
sudo npm install -g forever
forever的帮助手册
$ forever --help
usage: forever [action] [options] SCRIPT [script-options] Monitors the script specified in the current process or as a daemon actions:
start Start SCRIPT as a daemon
stop Stop the daemon SCRIPT by Id|Uid|Pid|Index|Script
stopall Stop all running forever scripts
restart Restart the daemon SCRIPT
restartall Restart all running forever scripts
list List all running forever scripts
config Lists all forever user configuration
set <key> <val> Sets the specified forever config <key>
clear <key> Clears the specified forever config <key>
logs Lists log files for all forever processes
logs <script|index> Tails the logs for <script|index>
columns add <col> Adds the specified column to the output in `forever list`
columns rm <col> Removed the specified column from the output in `forever list`
columns set <cols> Set all columns for the output in `forever list`
cleanlogs [CAREFUL] Deletes all historical forever log files options:
-m MAX Only run the specified script MAX times
-l LOGFILE Logs the forever output to LOGFILE
-o OUTFILE Logs stdout from child script to OUTFILE
-e ERRFILE Logs stderr from child script to ERRFILE
-p PATH Base path for all forever related files (pid files, etc.)
-c COMMAND COMMAND to execute (defaults to node)
-a, --append Append logs
-f, --fifo Stream logs to stdout
-n, --number Number of log lines to print
--pidFile The pid file
--uid Process uid, useful as a namespace for processes (must wrap in a string)
e.g. forever start --uid "production" app.js
forever stop production
--sourceDir The source directory for which SCRIPT is relative to
--workingDir The working directory in which SCRIPT will execute
--minUptime Minimum uptime (millis) for a script to not be considered "spinning"
--spinSleepTime Time to wait (millis) between launches of a spinning script.
--colors --no-colors will disable output coloring
--plain Disable command line colors
-d, --debug Forces forever to log debug output
-v, --verbose Turns on the verbose messages from Forever
-s, --silent Run the child script silencing stdout and stderr
-w, --watch Watch for file changes
--watchDirectory Top-level directory to watch from
--watchIgnore To ignore pattern when watch is enabled (multiple option is allowed)
--killSignal Support exit signal customization (default is SIGKILL),
used for restarting script gracefully e.g. --killSignal=SIGTERM
-h, --help You're staring at it [Long Running Process]
The forever process will continue to run outputting log messages to the console.
ex. forever -o out.log -e err.log my-script.js [Daemon]
The forever process will run as a daemon which will make the target process start
in the background. This is extremely useful for remote starting simple node.js scripts
without using nohup. It is recommended to run start with -o -l, & -e.
ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
forever stop my-daemon.js
使用forever启动项目
forever start app.js
使用forever停止项目
forever stop app.js
列出所有通过forever管理的项目
forever list
监视项目中的文件,当文件有变动时重启项目
forever -w start app.js
输出日志和错误
forever start -l forever.log -o out.log -e err.log app.js
Node.js 学习(七)Node项目部署工具之forever的更多相关文章
- Node.js学习笔记——Node.js开发Web后台服务
一.简介 Node.js 是一个基于Google Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效.Node.j ...
- Node.js学习(Node.js基础)
1.开发环境搭建 v8引擎是作为解析JavaScript程序来运行的 nodejs是一个高性能的,第一个体现在他的JavaScript解析速度很快,v8引擎性能很高,第二个事件驱动和非阻塞 2.全局对 ...
- [node.js学习]为node.js写的一个操作mysql的类
不支持一个对象在不同异步中使用,模仿的php框架 speedphp中的model模块 GaryMysql.js var mysql = require('mysql'); var pool = nul ...
- Node.js 学习笔记(一)--------- Node.js的认识和Linux部署
Node.js 一.Node.js 简介 简单的说 Node.js 就是运行在服务端的可以解析并运行 JavaScript 脚本的软件. Node.js 是一个基于Chrome JavaScript ...
- windows下安装node.js及环境配置、部署项目
windows下安装node.js及环境配置.部署项目 一.总结 一句话总结: 安装nodejs软件:就像普普通通的的软件那样安装 配置nodejs安装的全局模块的环境变量 并且安装cnpm(比如cn ...
- Node.js~在linux上的部署~pm2管理工具的使用
之前写了两篇关于在linux上部署nodejs的文章,大家如果没有基础可以先看前两篇<Node.js~在linux上的部署>,<Node.js~在linux上的部署~外网不能访问no ...
- 一点感悟:《Node.js学习笔记》star数突破1000+
写作背景 笔者前年开始撰写的<Node.js学习笔记> github star 数突破了1000,算是个里程碑吧. 从第一次提交(2016.11.03)到现在,1年半过去了.突然有些感慨, ...
- Node.js学习入门
Node.js是什么 Node.js是一个可以允许我们在服务器端运行JavaScript代码的程序. 这是什么意思呢?通常,我们写的JavaScript代码都是在浏览器中运行的. 实际上,浏览器就是一 ...
- Node.js学习笔记(1):Node.js快速开始
Node.js学习笔记(1):Node.js快速开始 Node.js的安装 下载 官方网址:https://nodejs.org/en/ 说明: 在Windows上安装时务必选择全部组件,包括勾选Ad ...
随机推荐
- grub丢失的修复
使用安装光盘进入rescure模式,经过配置后进入一个bashbash# grubgrub> root (hd0,6)grub> setup (hd0)重启即可
- ThinkPHP5中Session的使用
由于用惯了ThinkPHP之前的版本,一想到要用Session就直接用$_SESSION来存取,今天看了ThinkPHP5的手册,才发现原来这么用时不安全滴.ThinKPHP5对Session进行了封 ...
- xls数据导入sqlite数据库
protected void btn_ok_Click(object sender, EventArgs e) { try { st ...
- objective-C基本知识
预编译指令 1.自己写的头文件最好用双引号,而系统自带的可以用尖括号. ************************************************* 点语法 p.age= 10; ...
- mutex 简单介绍
“mutex”是术语“互相排斥(mutually exclusive)”的简写形式,也就是互斥量. 当两个或更多线程需要同时访问一个共享资源时,系统需要使用同步机制来确保一次只有一个线程使用该资源.M ...
- [leetcode]_Reverse Integer
经历了三道树的题后,完全崩溃中,急需一道非树图的题来挽救信心. 题目:反转数字.input : 123 , output : 321. 思路:直接,没什么好说的. 自己代码:很龊,有大量的冗余信息,还 ...
- 在SQL中取出字符串中数字部分或在SQL中取出字符部分
在SQL中取出字符串中数字部分或在SQL中取出字符部分 编写人:CC阿爸 2013-10-18 近来在开发一个项目时,一包含数字的字符串,需要取出中间的数字部分进行排序.经过baidu搜索.并结合自己 ...
- Cassandra 之 入门
1.到官网下载压缩包. http://cassandra.apache.org/download/ 我下载的是最新的 apache-cassandra-2.1.2-bin.tar.gz 另外:语言支持 ...
- 苹果Mac OS系统shell命令大全介绍
基本命令 1.列出文件 ls 参数 目录名 例: 看看驱动目录下有什么:ls /System/Library/Extensions 参数 -w 显示中文,-l 详细信息, -a 包括隐藏 ...
- PHP+MYSQL会员系统的开发实例教程
本文通过一个简单的实例完成了完整的PHP+MySQL会员系统功能.是非常实用的一个应用.具体实现步骤如下: 一.会员系统的原理: 登陆-->判断-->保持状态(Cookie或Session ...