node forever 安装使用
node源码安装
https://nodejs.org/zh-cn/download/
wget https://nodejs.org/dist/v14.17.0/node-v14.17.0.tar.gz
Unix and macOS
Unix prerequisites
gcc
andg++
>= 8.3 or newer, or- GNU Make 3.81 or newer
- Python 3.6, 3.7, 3.8, and 3.9 (see note above)
Installation via Linux package manager can be achieved with:
- Ubuntu, Debian:
sudo apt-get install python3 g++ make
- Fedora:
sudo dnf install python3 gcc-c++ make
- CentOS and RHEL:
sudo yum install python3 gcc-c++ make
- OpenSUSE:
sudo zypper install python3 gcc-c++ make
- Arch Linux, Manjaro:
sudo pacman -S python gcc make
FreeBSD and OpenBSD users may also need to install libexecinfo
.
macOS prerequisites
- Xcode Command Line Tools >= 11 for macOS
- Python 3.6, 3.7, 3.8, and 3.9 (see note above)
macOS users can install the Xcode Command Line Tools
by running xcode-select --install
. Alternatively, if you already have the full Xcode installed, you can find them under the menu Xcode -> Open Developer Tool -> More Developer Tools...
. This step will install clang
, clang++
, and make
.
Building Node.js
If the path to your build directory contains a space, the build will likely fail.
To build Node.js:
$ ./configure
$ make -j4
The -j4
option will cause make
to run 4 simultaneous compilation jobs which may reduce build time. For more information, see the GNU Make Documentation.
The above requires that python
resolves to a supported version of Python. See Prerequisites.
After building, setting up firewall rules can avoid popups asking to accept incoming network connections when running tests.
Running the following script on macOS will add the firewall rules for the executable node
in the out
directory and the symbolic node
link in the project's root directory.
$ sudo ./tools/macos-firewall.sh
Installing Node.js
To install this version of Node.js into a system directory:
[sudo] make install
forever 安装
-
$ npm install forever -g #安装
-
#设置软链接
-
ln -s /usr/software/nodejs/bin/forever /usr/local/bin/
一、node二进制安装
wget https://nodejs.org/dist/v10.15.2/node-v10.15.2-linux-x64.tar.xz // 下载 ###https://nodejs.org/zh-cn/download/
tar xf node-v10.15.2-linux-x64.tar.xz // 解压
cd node-v10.15.2-linux-x64/ // 进入解压目录
./bin/node -v // 执行node命令 查看版本
二、node软链接
# /usr/software/nodejs/bin/ 表示node解压后的目录
ln -s /usr/software/nodejs/bin/npm /usr/local/bin/
ln -s /usr/software/nodejs/bin/node /usr/local/bin/
三、查看版本
node -v
四、forever 安装
$ npm install forever -g #安装
#设置软链接
ln -s /usr/software/nodejs/bin/forever /usr/local/bin/
五、forever使用
#启动
forever start app.js
#关闭
forever stop app.js
#输出日志和错误
forever start -l forever.log -o out.log -e err.log app.js
#当前生产环境启动app命令
forever start -l /data2/fame_node/logs/forever.log -o /data2/fame_node/logs/out.log -e /data2/fame_node/logs/err.log app.js
start:启动守护进程
stop:停止守护进程
stopall:停止所有的forever进程
restart:重启守护进程
restartall:重启所有的foever进程
list:列表显示forever进程
config:列出所有的用户配置项
set <key> <val>: 设置用户配置项
clear <key>: 清楚用户配置项
logs: 列出所有forever进程的日志
logs <script|index>: 显示最新的日志
columns add <col>: 自定义指标到forever list
columns rm <col>: 删除forever list的指标
columns set<cols>: 设置所有的指标到forever list
cleanlogs: 删除所有的forever历史日志