Skip to content

Instantly share code, notes, and snippets.

@msigwart
Created November 13, 2023 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msigwart/86481464ecdeaae7b10297b43dfa07c8 to your computer and use it in GitHub Desktop.
Save msigwart/86481464ecdeaae7b10297b43dfa07c8 to your computer and use it in GitHub Desktop.
soketi-node-healthcheck
#!/usr/bin/env node
const http = require('node:http');
const options = {
hostname: 'localhost',
port: process.env.SOKETI_PORT || 6001,
path: '/',
method: 'GET'
};
http.request(options, res => {
let body = '';
res.on('data', chunk => {
body += chunk;
});
res.on('end', () => {
if (body === 'OK') {
process.stdout.write('We are healthy!');
process.exit(0);
} else {
process.stdout.write('Uh oh, we are not healthy!');
process.exit(1);
}
});
})
.on('error', () => {
process.stdout.write('Uh oh, we are not healthy!');
process.exit(1);
})
.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment