()
| 689 | } |
| 690 | |
| 691 | function checkHealth() { |
| 692 | var pids = getOwnedLoopPids(getRunningPids()); |
| 693 | if (pids.length === 0) return { healthy: false, reason: 'not_running' }; |
| 694 | var proxyHealth = checkProxyHealth(process.env); |
| 695 | if (!proxyHealth.healthy) { |
| 696 | return Object.assign({ healthy: false }, proxyHealth); |
| 697 | } |
| 698 | if (fs.existsSync(LOG_FILE)) { |
| 699 | var silenceMs = Date.now() - fs.statSync(LOG_FILE).mtimeMs; |
| 700 | if (silenceMs > MAX_SILENCE_MS) { |
| 701 | return { healthy: false, reason: 'stagnation', silenceMinutes: Math.round(silenceMs / 60000) }; |
| 702 | } |
| 703 | } |
| 704 | return { healthy: true, pids: pids }; |
| 705 | } |
| 706 | |
| 707 | // --- CLI --- |
| 708 | if (require.main === module) { |
no test coverage detected