[livingbody@localhost nodejstest]$ cnpm install -g supervisor Downloading supervisor to /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor_tmp Copying /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor_tmp/_supervisor@0.12.0@supervisor to /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor Installing supervisor's dependencies to /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor/node_modules All packages installed (used 3ms(network 2ms), speed 0B/s, json 0(0B), tarball 0B) [supervisor@0.12.0] link /usr/local/node-v10.13.0-linux-x64/bin/node-supervisor@ -> /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor/lib/cli-wrapper.js [supervisor@0.12.0] link /usr/local/node-v10.13.0-linux-x64/bin/supervisor@ -> /usr/local/node-v10.13.0-linux-x64/lib/node_modules/supervisor/lib/cli-wrapper.js
安装完后,可以用来启动node.js应用,当代码改动时,脚本会自动重启。
[livingbody@localhost nodejstest]$ supervisor app.js Running node-supervisor with program ‘app.js’ –watch ‘.’ –extensions ‘node,js’ –exec ‘node’ Starting child process with ‘node app.js’ Watching directory ‘/home/livingbody/nodejstest’ for changes. Press rs for restarting the process. HTTP SERVER IS listening at port 3000.