9 lines
548 B
JavaScript
9 lines
548 B
JavaScript
'use strict';
|
|
const https = require('node:https');
|
|
const req = https.get({ host: '127.0.0.1', port: Number(process.env.PEER_PORT || 8093), path: '/health', rejectUnauthorized: false,
|
|
timeout: 4000 }, res => {
|
|
let text = ''; res.on('data', chunk => { text += chunk; if (text.length > 1000) req.destroy(); });
|
|
res.on('end', () => { try { if (res.statusCode !== 200 || !JSON.parse(text).ok) process.exitCode = 1; } catch { process.exitCode = 1; } });
|
|
});
|
|
req.on('timeout', () => req.destroy()); req.on('error', () => { process.exitCode = 1; });
|