How to use the process.pid function in process

To help you get started, we’ve selected a few process 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 nearform / stats / index.js View on Github external
this._loopbench = undefined
  this._gcProfiler = gcProfiler
  this._gcs = []
  this._statsEmitterID = hyperid()

  this._emitInterval = reInterval(() => this.emit('stats', this._regenerateStats()), this._opts.sampleInterval * 1000)
  this._emitInterval.clear()

  const handlesInfo = this._getHandlesInfo()
  this.stats = {
    timestamp: new Date(),
    id: this._statsEmitterID,
    tags: this._opts.tags,
    process: {
      title: process.title,
      pid: process.pid,
      release: process.release,
      versions: process.versions,
      argv: process.argv,
      execArgv: process.execArgv,
      execPath: process.execPath,
      cpuUsage: this._getCpuUsage(),
      memoryUsage: process.memoryUsage(),
      // mainModule: process.mainModule,
      uptime: process.uptime(),
      handles: handlesInfo.handles,
      openServers: handlesInfo.openServers
    },
    system: {
      cpus: os.cpus(),
      uptime: os.uptime(),
      freemem: os.freemem(),
github airbrake / node-airbrake / lib / airbrake.js View on Github external
});
  }

  if (err.httpMethod) {
    cgiData.httpMethod = err.httpMethod;
  }

  Object.keys(err).forEach(function(key) {
    if (self.exclude.indexOf(key) >= 0) {
      return;
    }

    cgiData['err.' + key] = err[key];
  });

  cgiData['process.pid'] = process.pid;

  if (os.platform() !== 'win32') {
    // this two properties are *NIX only
    cgiData['process.uid'] = process.getuid();
    cgiData['process.gid'] = process.getgid();
  }

  cgiData['process.cwd'] = process.cwd();
  cgiData['process.execPath'] = process.execPath;
  cgiData['process.version'] = process.version;
  cgiData['process.argv'] = process.argv;
  cgiData['process.memoryUsage'] = process.memoryUsage();
  cgiData['os.loadavg'] = os.loadavg();
  cgiData['os.uptime'] = os.uptime();

  return cgiData;
github CenterForOpenScience / ember-osf-web / node-tests / helpers / check-config-types.js View on Github external
module.exports = function(environment) {
    const configJSON = JSON.stringify(config(environment));
    const configTS = `import config from 'config/environment'; const testConfig: typeof config = ${configJSON}`;
    const tsFile = `${os.tmpdir()}/check-config-types-${environment}-${process.pid}.ts`;
    fs.writeFileSync(tsFile, configTS);
    const result = spawnSync(
        'tsc',
        [
            tsFile,
            '--baseUrl', `${__dirname}/../../`,
            '--noEmit',
            '--skipLibCheck',
        ],
        { encoding: 'utf8' },
    );
    fs.unlinkSync(tsFile);
    return result;
};
github mweagle / Sparta / resources / provision / index.js View on Github external
var forwardToGolangProcess = function (event, context, callback, metricName, startRemainingCountMillisParam) {
    var startRemainingCountMillis = startRemainingCountMillisParam || context.getRemainingTimeInMillis()
    if (!golangProcess) {
      spartaUtils.log(util.format('Launching %s with args: execute --signal %d', SPARTA_BINARY_PATH, process.pid))
      golangProcess = childProcess.spawn(SPARTA_BINARY_PATH,
        ['execute',
          '--level',
          SPARTA_LOG_LEVEL,
          '--signal',
          process.pid], {
          'stdio': 'inherit'
        })
      var terminationHandler = function (eventName) {
        return function (value) {
          var onPosted = function () {
            console.error(util.format('Sparta %s: %s\n', eventName.toUpperCase(), JSON.stringify(value)))
            failCount += 1
            if (failCount > MAXIMUM_RESPAWN_COUNT) {
              process.exit(1)
            }
github fcavallarin / htcap / core / crawl / probe / analyze.js View on Github external
(async () => {
	const crawler = await htcrawl.launch(targetUrl, options);
	const page = crawler.page();
	var execTO = null;
	var domLoaded = false;
	var endRequested = false;
	var loginSeq = 'loginSequence' in options ? options.loginSequence : false;
	const pidfile = path.join(os.tmpdir(), "htcap-pids-" + process.pid);

	async function exit(){
		//await sleep(1000000)
		clearTimeout(execTO);
		await crawler.browser().close();
		fs.unlink(pidfile, (err) => {});
		process.exit();
	}

	async function getPageText(page){
		const el = await crawler.page().$("html");
		const v = await el.getProperty('innerText');
		return await v.jsonValue();
	}

	async function end(){
github bertolo1988 / saco / src / Server.ts View on Github external
this.app.use((req: Request, res: Response, next: Function) => {
                logInfo(datefmt(new Date(), this.options.dateformat), 'pid:', process.pid, 'ip:', req.ip, '\t', req.method, '\t', req.url);
                next();
            });
        }
github go2sh / cmake-integration-vscode / src / cmake / serverClient.ts View on Github external
private get pipeName(): string {
        if (process.platform === "win32") {
            return "\\\\?\\pipe\\" + this.name + "-" + process.pid + "-cmake";
        } else {
            return path.join(os.tmpdir(), this.name + "-" + process.pid + "-cmake.sock");
        }
    }
github EdgeVerve / oe-cloud / lib / common / mqtt-messaging-implementation.js View on Github external
*
 * ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
 * Bangalore, India. All Rights Reserved.
 *
 */
var mqtt = require('mqtt');
var app = require('../../server/server.js').app;
var process = require('process');
var os = require('os');
var mqttOptions = app.get('mqttOptions');

var logger = require('../logger');
var log = logger('util');

var client = mqtt.connect(mqttOptions);
var clientId = os.hostname() + '.' + process.pid;

module.exports = {
  init: init,
  publish: publish,
  subscribe: subscribe
};

client.on('connect', function clientConnectListnerFn() {
  log.info(log.defaultContext(), 'Connected to MQTT broker');
});

client.on('error', function clientErrorListnerFn(error) {
  log.info(log.defaultContext(), 'Error connecting to MQTT broker ', error);
});

client.on('offline', function clientOfflineListnerFn() {
github projectOpenRAP / OpenRAP / devmgmtV2 / middlewares / telemetry.middleware.js View on Github external
const addAgnosticDataAndSave = (telemetryData, actor, timestamp) => {
    let defer = q.defer();
    telemetryData = {
		...telemetryData,
		'ets' : timestamp.getTime(),
		'ver' : '3.0',
		'actor' : {
			'id' : actor
		},
		'context': {
			'channel' : 'OpenRAP',
			'pdata' : {
				'pid' : require('process').pid,
			},
			'env' : 'Device Management'
		}
	}

	_getSystemVersion()
		.then(systemVersion => {
			telemetryData = {
				...telemetryData,
				'context': {
					...telemetryData.context,
					'pdata' : {
						...telemetryData.context.pdata,
						'ver' : systemVersion.replace(/\n$/, '')
					}
				}
github SkyAPM / SkyAPM-nodejs / modules / nodejs-agent / lib / services / application-register-service.js View on Github external
function buildOsInfo() {
    let osInfoParameter = new DiscoveryServiceParameters.OSInfo();
    osInfoParameter.setOsname(os.platform());
    osInfoParameter.setHostname(os.hostname());
    osInfoParameter.setProcessno(process.pid);
    osInfoParameter.setIpv4sList(getAllIPv4Address());
    return osInfoParameter;
  }