Dependencies free library for docker container healthcheck using fs
npm i @tvorilas/node-healthchecker
Using on app side
import { HealthcheckServer } from '@tvorilas/node-healthchecker'
const healthcheckServer = new HealthcheckServer('/app/healthcheck.txt')
// Do something and call this method
healthcheckServer.ping()
Using in compose-file
services:
app:
healthcheck:
test: ["CMD", "node", "run", "health-check", "--", "/app/healthcheck.txt", "120000"] # 2 minutes in ms
interval: 5s
timeout: 20s
retries: 10