我一直在尝试使用node js对serverTwo函数中的第一台服务器进行健康检查。
这是我的代码。
const http = require('http');
const express = require('express');
http.createServer(serverOne).listen(8080);
http.createServer(serverTwo).listen(8081);
function serverOne (req, res) {
res.write('Server running at http://localhost:8080\n');
console.log("running serverOne\n");
res.end();
}
function serverTwo (req, res) {
res.write('Server running at http://localhost:8081\n');
console.log("running serverTwo\n");
res.end();
}