continous health check of first server inside second server using nodejs

4/11/2019

I've been trying to do health check of first server inside serverTwo function using node js.

  1. First i created two servers with two different ports using two different functions serverOne and serverTwo.
  2. Now I need to write code inside serverTwo function which will continuously check the health of serverOne.

Here is my code.

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();
}
-- LiN
express
kubernetes-health-check
node.js
server

0 Answers