博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Node项目部署工具之forever
阅读量:6589 次
发布时间:2019-06-24

本文共 3433 字,大约阅读时间需要 11 分钟。

  hot3.png

平常无论是使用命令行还是终端通过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 
Sets the specified forever config
clear
Clears the specified forever config
logs Lists log files for all forever processes logs
Tails the logs for
columns add Adds the specified column to the output in `forever list` columns rm Removed the specified column from the output in `forever list` columns set
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

转载于:https://my.oschina.net/lhplj/blog/360853

你可能感兴趣的文章
一些出的不错的Java面试题(一)
查看>>
记一次omi的项目之旅
查看>>
Android API级别、代号、发布时间及平台亮点整理
查看>>
Redis数据类型(上)
查看>>
安装配置nagios
查看>>
QQ第三方授权登录(带详细源码)
查看>>
HBase
查看>>
string 转换int
查看>>
rsync详解
查看>>
rsync通过服务同步、linux日志、screen工具
查看>>
吸血鬼教授vs狼人工程师
查看>>
LLDP(链路层发现协议)
查看>>
中国区Azure基本实例更新
查看>>
CentOS 6.5 Zabbix监.控系统功能及基本使用
查看>>
Ubuntu14 添加程序启动
查看>>
我的友情链接
查看>>
常见数据类型的手机二维码生成与识别格式参考
查看>>
windows网络安全以及常见网络***方式
查看>>
警告 初始化默认驱动器时出错“找不到运行 Active Directory Web 服务的默认服务器。”...
查看>>
Irssi Error [Cannot assign requested address: x.x.x.x]
查看>>