Skip to content

Commit

Permalink
Merge pull request #74 from flowforge/fix-healthcheck
Browse files Browse the repository at this point in the history
Fix healthcheck
  • Loading branch information
Steve-Mcl committed Dec 3, 2022
2 parents cc0d2b7 + 9a30860 commit 240b32b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions node-red-container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG BUILD_TAG=latest
RUN if [[ ! -z "$REGISTRY_TOKEN" ]]; then echo "//$REGISTRY/:_authToken=$REGISTRY_TOKEN" >> ~/.npmrc ; fi
RUN if [[ ! -z "$REGISTRY" ]] ; then npm config set @flowforge:registry "https://$REGISTRY"; fi

COPY healthcheck.js /healthcheck.js

COPY package.json /data
WORKDIR /data
RUN npm install
Expand Down
2 changes: 2 additions & 0 deletions node-red-container/Dockerfile-2.2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG BUILD_TAG=latest
RUN if [[ ! -z "$REGISTRY_TOKEN" ]]; then echo "//$REGISTRY/:_authToken=$REGISTRY_TOKEN" >> ~/.npmrc ; fi
RUN if [[ ! -z "$REGISTRY" ]] ; then npm config set @flowforge:registry "https://$REGISTRY"; fi

COPY healthcheck.js /healthcheck.js

COPY package.json /data
WORKDIR /data
RUN npm install
Expand Down
24 changes: 24 additions & 0 deletions node-red-container/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var http = require('http');
var https = require('https');
var request;

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;

var options = {
host: "localhost",
port: 2880,
timeout: 4000
};

request = http.request(options, (res) => {
//console.log(`STATUS: ${res.statusCode}`);
if ((res.statusCode >= 200) && (res.statusCode < 500)) { process.exit(0); }
else { process.exit(1); }
});

request.on('error', function (err) {
//console.log('ERROR',err);
process.exit(1);
});

request.end();

0 comments on commit 240b32b

Please sign in to comment.