通常我们会使用ssh工具连接远程的云主机部署运行web应用,但是当我们断开ssh回话后,应用也随之断开,那么有什么方法能使得应用不受ssh断开的影响呢?当然有方法!
一种方法大家可以参考《Linux下使Shell 命令脱离终端在后台运行》。
今天我们主要来介绍怎么使用forever管理node应用。
安装
npm install -g forever
使用
- 启动应用
forever start app.js
- 停止应用
forever stop app.js
更多参数
$ 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