2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-14 00:54:07 +00:00
frappe_docker/build/frappe-socketio/health.js
2020-02-10 15:59:11 +05:30

20 lines
597 B
JavaScript

var net = require('net');
var { get_conf } = require('./node_utils');
var conf = get_conf();
var server = ['localhost', conf.socketio_port || 9000];
var sock = new net.Socket();
sock.setTimeout(2500);
sock.on('connect', function() {
console.info(server[0]+':'+server[1]+' is up.');
sock.destroy();
process.exit();
}).on('error', function(e) {
console.error(server[0]+':'+server[1]+' is down: ' + e.message);
process.exit(1);
}).on('timeout', function(e) {
console.error(server[0]+':'+server[1]+' is down: timeout');
process.exit(1);
}).connect(server[1], server[0]);