使用nodejs对第二台服务器内的第一台服务器进行连续运行状况检查

时间:2019-04-11 15:10:21

标签: node.js express server kubernetes-health-check

我一直在尝试使用node js对serverTwo函数中的第一台服务器进行健康检查。

  1. 首先,我使用两个不同的功能serverOne和serverTwo创建了两个具有两个不同端口的服务器。
  2. 现在我需要在serverTwo函数中编写代码,该函数将不断检查serverOne的运行状况。

这是我的代码。

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();
}

0 个答案:

没有答案
相关问题