src/Manager.js
function Manager (remote) {

	/** Allow usage without `new`. */
	if (!(this instanceof Manager)) {
		return new Manager(remote);
	}

	/**
	 * @property {Boolean} isRemote
	 * Whether the manager is remote.
	 */
	this.isRemote = false;

	/**
	 * @property {Socket} socket
	 * A socket.io instance, or `null` if using locally.
	 */
	this.socket = null;

	/** If only using locally, stop here. */
	if (!remote) {
		return this;
	}

	/** If it's a URL, connect to it. */
	if (typeof remote === 'string') {
		this.isRemote = true;

		/** Automatically postfix the manager scope. */
		var url = remote + '/panic-manager';

		/** Connect to the remote manager. */
		this.socket = socket.client(url);

		return this;
	}

	/** Listen for /panic-manager connections. */
	var server = socket.server(remote).of('/panic-manager');

	/** Listen for connections. */
	server.on('connection', function (socket) {

		/** Listen for start commands. */
		socket.on('start', function (config) {
			spawn(config);
		});

	});

	this.socket = server;

}
function Manager (remote) {

	/** Allow usage without `new`. */
	if (!(this instanceof Manager)) {
		return new Manager(remote);
	}

	/**
	 * @property {Boolean} isRemote
	 * Whether the manager is remote.
	 */
	this.isRemote = false;

	/**
	 * @property {Socket} socket
	 * A socket.io instance, or `null` if using locally.
	 */
	this.socket = null;

	/** If only using locally, stop here. */
	if (!remote) {
		return this;
	}

	/** If it's a URL, connect to it. */
	if (typeof remote === 'string') {
		this.isRemote = true;

		/** Automatically postfix the manager scope. */
		var url = remote + '/panic-manager';

		/** Connect to the remote manager. */
		this.socket = socket.client(url);

		return this;
	}

	/** Listen for /panic-manager connections. */
	var server = socket.server(remote).of('/panic-manager');

	/** Listen for connections. */
	server.on('connection', function (socket) {

		/** Listen for start commands. */
		socket.on('start', function (config) {
			spawn(config);
		});

	});

	this.socket = server;

}
function Manager ( remote ) { /** Allow usage without `new`. */ if ( ! ( this instanceof Manager ) ) { return new Manager ( remote ) ; } /**
	 * @property {Boolean} isRemote
	 * Whether the manager is remote.
	 */ this . isRemote = false ; /**
	 * @property {Socket} socket
	 * A socket.io instance, or `null` if using locally.
	 */ this . socket = null ; /** If only using locally, stop here. */ if ( ! remote ) { return this ; } /** If it's a URL, connect to it. */ if ( typeof remote === 'string' ) { this . isRemote = true ; /** Automatically postfix the manager scope. */ var url = remote + '/panic-manager' ; /** Connect to the remote manager. */ this . socket = socket . client ( url ) ; return this ; } /** Listen for /panic-manager connections. */ var server = socket . server ( remote ) . of ( '/panic-manager' ) ; /** Listen for connections. */ server . on ( 'connection' , function ( socket ) { /** Listen for start commands. */ socket . on ( 'start' , function ( config ) { spawn ( config ) ; } ) ; } ) ; this . socket = server ; }
Manage panic clients in bulk, either locally or remotely.

@class Manager
@param {Mixed} remote - Either an http.Server to attach to,
a URL to connect to, or `undefined` if there is no remote.
Manage panic clients in bulk either locally or remotely .