How to use the process.on 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 Domiii / NoGap / samples / HelloWorld / HelloWorld.js View on Github external
/**
 * Self-contained HelloWorld example.
 */
"use strict";

const process = require('process');
process.on('uncaughtException', function (err) {
    console.error('[UNCAUGHT ERROR]');
    console.error(err.stack);
});

global.Promise = require("bluebird");


// ##########################################################################
// Define HelloWorld component

var NoGapDef = require('nogap').Def;

NoGapDef.component({
	Client: NoGapDef.defClient(function(Tools, Instance, Context) {
		return {
			initClient: function() {
github jdstroy / JavaPoly / src / dispatcher / NodeSystemDispatcher.js View on Github external
process.on('beforeExit', () => {
      // console.log("before exit: ", _this.count);
      if (!_this.terminating) {
        WrapperUtil.dispatchOnJVM(javapoly, 'TERMINATE', 0, [], (willTerminate) => {
          _this.count++;
          _this.terminating = willTerminate;
          if (!willTerminate) {
            setTimeout(() => { }, 500);    // breathing space to avoid busy polling. TODO: Exponential backoff with ceiling
          } else {
            WrapperUtil.dispatchOnJVM(javapoly, 'TERMINATE_NOW', 0, [], (willTerminate) => { });
          }
        });
      }
    });

    process.on('exit', () => {
      // console.log("node process Exit");
      _this.terminating = true;
    });

    process.on('SIGINT', () => {
      _this.terminating = true;
      WrapperUtil.dispatchOnJVM(javapoly, 'TERMINATE_NOW', 0, [], (willTerminate) => { });
    });

    process.on('uncaughtException', (e) => {
      console.log("Uncaught exception: " + e);
      console.log("stack: " + e.stack);
      _this.terminating = true;
      WrapperUtil.dispatchOnJVM(javapoly, 'TERMINATE_NOW', 0, [], (willTerminate) => { });
    });
github uber-archive / hyperbahn / benchmarks / hyperbahn-worker.js View on Github external
id: 'http://bs:bs@localhost:' + self.sentryPort
            },
            'tchannel.host': '127.0.0.1',
            'hyperbahn.ringpop.bootstrapFile': self.ringpopList
        }
    });
};

if (require.main === module) {
    var argv = readBenchConfig();
    process.title = 'nodejs-benchmarks-hyperbahn_worker';

    var worker = HyperbahnWorker(argv);

    // attach before throwing exception
    process.on('uncaughtException', worker.app.clients.onError);
    worker.start();
}
github d3x0r / sack.vfs / tests / sack_test4.js View on Github external
_x = event.x;
			_y = event.y;
			_b = event.b;
		} else {
			_b = event.b;
		}
		return true;
	}
} );

f.Control( "image control", 0, 40, 500, 500 );

f.show();

var process = require( 'process' );
process.on('exit', function (){
  console.log('Goodbye!');
  f.close();
});

process.on('SIGINT', function (){
  console.log('Goodbye!');
  f.close();
});
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / Compile.js View on Github external
let configDb = await qx.tool.cli.ConfigDb.getInstance();
      if (this.argv["feedback"] === null) {
        this.argv["feedback"] = configDb.db("qx.default.feedback", true);
      }

      if (this.argv["machine-readable"]) {
        qx.tool.compiler.Console.getInstance().setMachineReadable(true);
      } else {
        let configDb = await qx.tool.cli.ConfigDb.getInstance();
        let color = configDb.db("qx.default.color", null);
        if (color) {
          let colorOn = consoleControl.color(color.split(" "));
          process.stdout.write(colorOn + consoleControl.eraseLine());
          let colorReset = consoleControl.color("reset");
          process.on("exit", () => process.stdout.write(colorReset + consoleControl.eraseLine()));
          let Console = qx.tool.compiler.Console.getInstance();
          Console.setColorOn(colorOn);
        }

        if (this.argv["feedback"]) {
          var themes = require("gauge/themes");
          var ourTheme = themes.newTheme(themes({hasUnicode: true, hasColor: true}));
          let colorOn = qx.tool.compiler.Console.getInstance().getColorOn();
          ourTheme.preProgressbar = colorOn + ourTheme.preProgressbar;
          ourTheme.preSubsection = colorOn + ourTheme.preSubsection;
          ourTheme.progressbarTheme.postComplete += colorOn;
          ourTheme.progressbarTheme.postRemaining += colorOn;

          this.__gauge = new Gauge();
          this.__gauge.setTheme(ourTheme);
          this.__gauge.show("Compiling", 0);
github aprice- / redisclustercompose / discover / index.js View on Github external
if (portInfo && cportInfo) {
				let port = portInfo[0].HostPort;
				let cport = cportInfo[0].HostPort;

                res.send(`${clusterAnnounceIp}:${port}@${cport}`);
			} else {
				res.send('');
			}
		}
	});
});

let server = app.listen(3000);

process.on('SIGINT', () => {
    server.close(() => {
        process.exit();
    });
});
github ehmicky / log-process-errors / src / setup.js View on Github external
const addListener = function({ opts, eventName, eventFunc }) {
  const eventListener = eventFunc.bind(null, { opts, eventName })
  process.on(eventName, eventListener)

  return { eventListener, eventName }
}
github photostructure / exiftool-vendored.js / src / exiftool.ts View on Github external
constructor(
    readonly maxProcs: number = 1,
    readonly maxReuses: number = 100,
    readonly taskTimeoutMillis: number = 10000,
    readonly onIdleIntervalMillis: number = 2000
  ) {
    if (onIdleIntervalMillis > 0) {
      setInterval(() => this.onIdle(), onIdleIntervalMillis).unref()
    }
    _process.on("exit", () => this.end())
  }