Skip to content

Commit 2ab2d38

Browse files
committed
add hostname to livenessprobe
1 parent dd63359 commit 2ab2d38

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

OpenFlow/src/WebServer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as os from "os";
12
import * as path from "path";
23
import * as http from "http";
34
import * as https from "https";
@@ -22,6 +23,7 @@ import { WebSocketServer } from "./WebSocketServer";
2223
import { WebSocketServerClient } from "./WebSocketServerClient";
2324
import { Counter } from "@opentelemetry/api-metrics"
2425
import { Logger } from "./Logger";
26+
var _hostname = "";
2527

2628
const BaseRateLimiter = new RateLimiterMemory({
2729
points: Config.api_rate_limit_points,
@@ -115,6 +117,11 @@ export class WebServer {
115117
this.app.use(flash());
116118
if (Config.api_rate_limit) this.app.use(rateLimiter);
117119

120+
this.app.get("/livenessprobe", (req: any, res: any, next: any): void => {
121+
if (NoderedUtil.IsNullEmpty(_hostname)) _hostname = (Config.getEnv("HOSTNAME", undefined) || os.hostname()) || "unknown";
122+
res.end(JSON.stringify({ "success": "true", "hostname": _hostname }));
123+
res.end();
124+
});
118125

119126
// Add headers
120127
this.app.use(function (req, res, next) {

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.2.106",
3+
"version": "1.2.107",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

OpenFlowNodeRED/src/WebServer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as os from "os";
12
import * as path from "path";
23
import * as http from "http";
34
import * as https from "https";
@@ -24,6 +25,7 @@ import { hrTime } from "@opentelemetry/core";
2425
import * as RED from "node-red";
2526
import { Red } from "node-red";
2627
import { Logger } from "./Logger";
28+
var _hostname = "";
2729

2830
export class log_message_node {
2931
public span: Span;
@@ -70,7 +72,6 @@ export class log_message {
7072
this.span.setAttribute("name", this.name)
7173
}
7274
}
73-
7475
export class WebServer {
7576
private static app: express.Express = null;
7677

@@ -347,7 +348,8 @@ export class WebServer {
347348
this.app.use(this.settings.httpNodeRoot, RED.httpNode);
348349

349350
this.app.get("/livenessprobe", (req: any, res: any, next: any): void => {
350-
res.end(JSON.stringify({ "success": "true" }));
351+
if (NoderedUtil.IsNullEmpty(_hostname)) _hostname = (Config.getEnv("HOSTNAME", undefined) || os.hostname()) || "unknown";
352+
res.end(JSON.stringify({ "success": "true", "hostname": _hostname }));
351353
res.end();
352354
});
353355

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.106
1+
1.2.107

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.2.106",
3+
"version": "1.2.107",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)