0.1.0 • Published 6 years ago

@aftonbladet/health-check v0.1.0

Weekly downloads
1
License
UNLICENSED
Repository
github
Last release
6 years ago

A simple Javascript round robin health checker

Install

npm install @aftonbladet/health-check --save

Usage

Simple initialization

import { initHealthCheck, isHealthy } from '@aftonbladet/health-check';

initHealthCheck({ healthCheckUrls: ['http://www.aftonbladet.se/'] });

if (isHealthy()) {
    // System is UP
} else {
    // System is DOWN!
}

This will initialize a health checker that checks http://www.aftonbladet.se every three seconds. If any of five consecutive checks returns a status in the 200 to 299 range, the check is considered to be healthy.

Advanced initialization

import { initHealthCheck, isHealthy } from '@aftonbladet/health-check';

initHealthCheck({
	healthCheckUrls: ['http://www.aftonbladet.se/', 'https://www.aftonbladet.se/sportbladet'],
	healthCheckInterval, 1000,
	numberOfChecks: 3,
});

if (isHealthy()) {
    // System is UP
} else {
    // System is DOWN!
}

This will instead initialize a health checker that round robins through the URLs in healthCheckUrls every second. If any of three consecutive checks returns a status in the 200 to 299 range, the check is considered to be healthy.

The following parameters are accepted by initHealthCheck:

Publish

npm version major|minor|patch