Add healthcheck script

This commit is contained in:
2022-01-02 15:11:10 +03:00
parent 58390a577c
commit 0d142c1dd8
2 changed files with 21 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ FROM node:lts-alpine as runtime-image
WORKDIR /root/app WORKDIR /root/app
COPY ./package.json ./ COPY ./package.json ./
COPY ./scripts/healthcheck.js ./
RUN npm i --only=production RUN npm i --only=production

20
scripts/healthcheck.js Normal file
View File

@@ -0,0 +1,20 @@
(async () => {
const http = await import('http');
const healthCheck = http.request("http://localhost:8080/healthcheck", (res) => {
console.log(`HEALTHCHECK STATUS: ${res.statusCode}`);
if (res.statusCode == 200) {
process.exit(0);
}
else {
process.exit(1);
}
});
healthCheck.on('error', function (err) {
console.error('ERROR');
process.exit(1);
});
healthCheck.end();
})();