1.说明
supervisor
会一直watch
应用下的所有文件,发现文件被修改,就重新载入程序文件,类似于其他编程语言中debug
模式下的reload
2.使用
npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm install -g supervisor
- 2.使用
supervisor
提代node
命令启动应用
λ supervisor first.js
Running node-supervisor with
program 'first.js'
--watch '.'
--extensions 'node,js'
--exec 'node'
Starting child process with 'node first.js'
Watching directory 'F:\projects\nodejs\demo1' for changes.
Press rs for restarting the process.
const http = require('http');
const url = require("url")
http.createServer(function(request, response){
if (request.url.includes("?")) {
var urlObj = url.parse(request.url)
console.log(urlObj.query)
}
response.setHeader('Content-Type', 'text/html; charset=utf-8');
response.statusCode = 200;
response.statusMessage = "OK-200";
response.write("hello 世界!");
response.end();
}).listen(9999);