ITS-Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Nodebb Healthcheck

    Scheduled Pinned Locked Moved IT-Stuff
    1 Posts 1 Posters 38 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      admin
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB | Contributors