How to use the os.hostname function in os

To help you get started, we’ve selected a few os examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hmalphettes / log4js-elasticsearch / test / test-eslogger.js View on Github external
index: function(indexName, typeName, logObj, newLogId, cb) {
      expect(indexName).to.match(/^logstash-/);
      expect(typeName).to.equal('nodejs');
      expect(newLogId).to.not.exist;
      expect(logObj['@fields'].category).to.equal('unittest');
      expect(logObj['@source']).to.equal('log4js');
      expect(logObj['@source_host']).to.equal(require('os').hostname());
      expect(logObj['@source_path']).to.equal(process.cwd());
      expect(logObj['@tags'].length).to.equal(0);
      if (currentMsg) {
        expect(logObj['@message']).to.equal(currentMsg);
        currentMsg = null;
      } else {
        expect(logObj['@message']).to.exist;
      }
      if (currentErrorMsg) {
        expect(currentErrorMsg).to.equal(logObj['@fields'].error);
        expect(logObj['@fields'].stack).to.be['instanceof'](Array);
        currentErrorMsg = null;
      }
      if (currentLevelStr) {
        expect(logObj['@fields'].levelStr).to.equal(currentLevelStr);
        currentLevelStr = null;
github xdamman / tipbox / server / index.js View on Github external
logger.error('Uncaught Exception', err);
  logger.error(err.stack);
});

process.on('SIGTERM', function() {
  logger.info("Received SIGTERM");

  app.jobs.runAll(function() {
    logger.info("All jobs done, exiting");
    process.exit(0);
  });

});

var port = process.env.PORT || 3000;
var host = process.env.HOST || os.hostname() || 'localhost';
logger.prod("Listening on " + host + ":" + port+" in "+app.get('env')+" environment, pid: "+process.pid);
app.listen(port, host);
github tinganho / connect-modrewrite / index.js View on Github external
/**
 * Module dependencies
 */

var url = require('url');
var qs = require('qs');
var httpReq = require('http').request;
var httpsReq = require('https').request;
var defaultVia = '1.1 ' + require('os').hostname();

/**
 * Syntaxes
 */

var noCaseSyntax = /NC/;
var lastSyntax = /L/;
var proxySyntax = /P/;
var redirectSyntax = /R=?(\d+)?/;
var forbiddenSyntax = /F/;
var goneSyntax = /G/;
var typeSyntax = /T=([\w|\/]+,?)/;
var hostSyntax =  /H=([^,]+)/;
var flagSyntax = /\[([^\]]+)]$/;
var partsSyntax = /\s+|\t+/g;
var httpsSyntax = /^https/;
github moleculerjs / moleculer-cli / src / connect-handler.js View on Github external
if (config.logger === undefined)
		config.logger = true;

	if (opts.ns)
		config.namespace = opts.ns;

	if (opts.connectionString)
		config.transporter = opts.connectionString;
	else if (config.nodeID === undefined && opts._[0] == "connect")
		config.transporter = "TCP";

	if (opts.id)
		config.nodeID = opts.id;
	else if (config.nodeID === undefined)
		config.nodeID = `cli-${os.hostname().toLowerCase()}-${process.pid}`;

	if (opts.serializer)
		config.serializer = opts.serializer;

	if (opts.hot)
		config.hotReload = opts.hot;

	if (replCommands)
		config.replCommands = replCommands;

	const broker = new Moleculer.ServiceBroker(config);

	broker.start().then(() => broker.repl());
};
github joola / joola / lib / dispatch / system.js View on Github external
run: function (context, node, callback) {
    callback = callback || function () {
    };
    var found = false;
    if (node.hostname == os.hostname()) {
      found = true;
      joola.logger.info('Detected request to start web server in exchange of [' + node.uid + '], allowing grace...');
      setTimeout(function () {
        joola.logger.info('Attempting start of web server in exchange of [' + node.uid + ']');
        joola.webserver.start({}, function (err) {
          if (err)
            return callback(err);
          return callback(null, true);
        });
      }, 3000);
    }
    if (!found)
      return callback(null);
  }
};
github beaugunderson / mdns-swarm / dns-sd.js View on Github external
function Service(name) {
  events.EventEmitter.call(this);

  this.debug = debug(['dns-sd', name].join(':'));

  this.name = name;
  this.hostname = os.hostname();

  this.mdnsName = '_' + name + '._tcp.local';
  this.mdnsHostname = this.hostname + '.' + this.mdnsName;
}
github moleculerjs / moleculer / examples / docker / client / moleculer.config.js View on Github external
"use strict";

const hostname = require("os").hostname();

module.exports = {
	namespace: "docker",
	nodeID: `client-${hostname}`,
	logger: true,
	logLevel: "info",
	transporter: {
		type: "TCP",
		options: {
		}
	},

	started(broker) {
		let reqCount = 0;
		broker.waitForServices("worker").then(() => {
			setInterval(() => {
github trwalker / generator-express-rest-api / generators / app / templates / app / config / settings / settings-config.js View on Github external
function loadServerSettings(settings) {
  settings.serverName = os.hostname().toLowerCase();
  settings.serverCores = os.cpus().length;
}
github FabMo / FabMo-Engine / detection_daemon.js View on Github external
function getMachineInfo(){
	var result = {};
	result.hostname= os.hostname();
	result.networks=[];
	result.server_port = config.engine.get('server_port');
	try {
	Object.keys(os.networkInterfaces() || {}).forEach(function(key,index,arr){ //val = ip adresses , key = name of interface
		var networks_list = this;
		(networks_list[key]||{}).forEach(function(val2,key2,arr2){
			if (val2.internal === false && val2.family === 'IPv4')
			{
				result.networks.push({'interface' : key , 'ip_address' : val2.address});
			}
		});
	},os.networkInterfaces());
	} catch(e) {
		log.warn(e);
	}
	return result;