Nodebb Healthcheck
-
Hi,
first we need the check in nodebb/.docker/config
vi healtcheck.js
const http = require('http'); const options = { host: '127.0.0.1', port: 4567, timeout: 2000 }; const healthCheck = http.request(options, (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();
Then we can add the check in our yml File
healthcheck: test: ["CMD", "node", "/opt/config/healthcheck.js"] interval: 5s timeout: 3s retries: 5 start_period: 15s
To check if everything is Working we can watch docker ps, it should be healthy there or use docker inspeckt
docker inspect --format='{{json .State.Health}}' <container-id>
Greetings