mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Add healthcheck script
This commit is contained in:
@@ -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
20
scripts/healthcheck.js
Normal 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();
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user