0.1.15 • Published 10 years ago

mrphealthcheck v0.1.15

Weekly downloads
-
License
MIT
Repository
-
Last release
10 years ago

Health Check Circle CI

Simple and highly customisable JSON health check builder.

  npm install mrphealthcheck --save
var status = require('mrphealthcheck');

var results = status({
  "name": "some-app",
  "checks": [
    {
      "name": "mr-porter product page",
      "url" : "http://mrporter.com"
    },
    {
      "name": "Google",
      "url" : "http://google.com"
    }
  ]

}).then( function(data) {
  // {JSON data}
})

Product Page Example:

/**
 * Class - healthMiddleware - executes healthcheck module for a given route 
 *
 * @class healthMiddleware
 * @static
 * @example app.use('/health/check', require('mrphealthcheck');
 */
module.exports = function(req, res) {

	var os = require('os');

	var appUrl = req.protocol + '://' + req.get('host');
	var build = rootRequire('build.json') || {};
	var results = require('mrphealthcheck')({
		'name': 'Mr Porter Product Page',
		"uptimeSeconds": parseInt(process.uptime(), 10),
		'buildTime': build.buildTime,
		"env": req.app.settings.env, //set consistently by server.init
		"nodeVersion": process.versions.node,
		"buildNumber": build.tag,
		"buildUrl": "http://xyz/jenkins/job/CI-mrp_product-page/" + build.tag,
		"gitCommit": build.commit,
		"gitUrl": "http://xyz/product-page/commits/" + build.commit,
		"host": {
			"hostname": os.hostname(),
			"uptimeSeconds": parseInt(os.uptime(), 10)
		},
		"checks": [
			{
				'name': 'Check Product Page App',
				'url': appUrl
			},
			{
				'name': 'LAD API Product Details',
				'url': "http://xyz:80/categories?business=MRP&country=GB&lang=en"
			}
		]

	});

	results.then(function(healthCheck) {
		res.json(healthCheck);
	});

};

Generic Output Example:

{
	"application": {
	  "name": "My App",
  	"bootTime": "2014-02-28T15:30:00Z",
  	"buildTime": "2014-02-28T15:30:00Z",
  	"uptimeSeconds": 300,
  	"version": "1.0.0",
	  "buildNumber": 55,
	  "buildUrl": "http://jenkins01.vm.wtf.nap:8080/jenkins/job/CI-my-app/55/",
	  "gitCommit": "860760dbba4e131209e458c61979895e5d51a8c4",
    "configuration": {
    	// Application specific configuration
    },
    "metrics": {
    	// Application specific metrics (request/second, etc)
    },
    "checks": [
			{
				"name": "mr-porter product page",
				"result": "FAILED", // SUCCESS, or FAILED
				"dateOfCheck": "2015-04-27T11:34:46.336Z",
			}
		]
	},
	"host": {
	  "currentTime": "2015-04-27T11:34:46.336Z",
	  "bootTime": "2015-04-27T11:34:46.336Z",
    "uptimeSeconds": 300,
	  "hostname": "dev-myApp"
	}
}
0.1.15

10 years ago

0.1.14

10 years ago

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago