Code coverage report for kardia/index.js

Statements: 88.89% (16 / 18)      Branches: 50% (4 / 8)      Functions: 100% (3 / 3)      Lines: 88.89% (16 / 18)      Ignored: none     

All files » kardia/ » index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391     1           1       1 20 20   18 18     18 18 18     18 18     18   18       1    
(function() {
	'use strict';
 
	var currentStatus = null,
		cluster = require('cluster'),
		Status = require(__dirname + '/lib/status.js');
 
	// if running on a cluster worker, we assume the master already has Kardia started, thus we
	// instantiate a wrapper instance right-away
	Iif (!cluster.isMaster) {
		currentStatus = new Status({});
		module.exports = currentStatus;
	} else {
		var startHandler = function(config) {
			Eif (currentStatus === null) {
				currentStatus = new Status(config);
 
				Eif (!currentStatus._instanceId) {
					currentStatus._instanceId = Date.now()+'.'+Math.round(Math.random()*1000);
				}
 
				currentStatus.on('serverStopped', function() {
					currentStatus = null;
					module.exports = { start: startHandler };
				});
 
				Eif (cluster.isMaster) {
					currentStatus.startServer();
				}
 
				module.exports = currentStatus;
			}
			return currentStatus;
		};
 
		// otherwise only expose the .start() command, which in turn returns the currentStatus.
		module.exports.start = startHandler;
	}
})();