src/server/graceful_express.js
function GracefulExpress(options) {
  options = options || {};

  this.server = null;
  this.graceful = null;

  var startFile = process.mainModule.filename;
  this._setOption('inProcessTest', options, /mocha$/.test(startFile));

  this.reaperPollInterval = options.reaperPollInterval || 500;
  util.verifyType('number', this, 'reaperPollInterval');

  this.shuttingDown = false;
  this._serverClosed = false;

  this._responses = [];
  this._sockets = [];
  this._activeSockets = [];

  //both here for symmetry; unlikely that both of these are available on construction
  this.setGraceful(options.graceful || Graceful.instance);
  this.setServer(options.server);

  this.middleware = this.middleware.bind(this);
}
function GracefulExpress(options) {
  options = options || {};

  this.server = null;
  this.graceful = null;

  var startFile = process.mainModule.filename;
  this._setOption('inProcessTest', options, /mocha$/.test(startFile));

  this.reaperPollInterval = options.reaperPollInterval || 500;
  util.verifyType('number', this, 'reaperPollInterval');

  this.shuttingDown = false;
  this._serverClosed = false;

  this._responses = [];
  this._sockets = [];
  this._activeSockets = [];

  //both here for symmetry; unlikely that both of these are available on construction
  this.setGraceful(options.graceful || Graceful.instance);
  this.setServer(options.server);

  this.middleware = this.middleware.bind(this);
}
/*
The `constructor` has some optional parameters:

+ `graceful` - required to enable full server shutdown scenarios. Can be set either on
construction or later with `listen()` or `setGraceful()`. Default is `Graceful.instance`,
so if you've created an instance in this process already, it will be found automatically.
+ `server` - the http server, though unlikely to be available on construction of this
class. More likely you'll use `listen()` or `setServer()` later - see below.
+ `inProcessTest` - if set to true, will prevent domains from being set up for every
request, enabling in-process testing of your endpoints, as is often done with `supertest`.
Defaults to true if we can detect that this is a `mocha` run.