Run middleware pipeline
@param {Function} callback
187698
function run (files, callback) {
  let self = this,
    i = 0;

  function next(err, files) {
    let mw = self.middleware[i++];

    if (mw) {
      mw(files, self, next);
    }
    else {
      callback(null, files);
    }

  };

  next(null, files);
}
581094
async function startApp(middlewareConfig, config) {
  const {
    port = DEFAULT_PORT,
    host = DEFAULT_HOST,
  } = config

  // close all connections when running nodemon
  const sigListener = async () => {
    await app.destroy()
    process.kill(process.pid, 'SIGUSR2')
  }
  process.once('SIGUSR2', sigListener)

  const appMeta = await createApp(middlewareConfig, config)
  const { app } = appMeta

  const server = await listen(app, port, host)

  enableDestroy(server)
  app.destroy = async () => {
    await destroy(server)
    process.removeListener('SIGUSR2', sigListener)
  }
  const { port: p } = server.address()

  const url = `http://localhost:${p}`

  const router = new Router()

  return { ...appMeta, router, url, server }
}
293665
function(process, callback) {
    if (callback !== undefined && typeof callback === 'function') {
      CALLBACK = callback
    }
    if (cluster.isMaster) {
      process.on('message', masterHandler)
    }
    else {
      process.on('message', workerHandler)
    }
  }
63305
function _runFlow(cmd, callback) {
  execFile(flow, cmd, {
    cwd: module.__dirname
  }, function (err, stdout, stderr) {
    if (err && stdout.length > 0) {
      return callback(new $.util.PluginError('flow', stdout));
    } else if (err) {
      $.util.log(stderr);
      return callback(err);
    } else { // eslint-disable-line
      callback();
    }
  });
}
151983
function (callback) {
                var self = this;
                flow()
                    .seq(function (cb) {
                        self.$handlers.stop(function () {
                            // ignore errors during stop
                            cb();
                        });
                    })
                    .seq(function (cb) {
                        self.$authenticationService.stop(function () {
                            cb();
                        });
                    })
                    .seq(function (cb) {
                        self.$filters.stop(function () {
                            // ignore errors during stop
                            cb();
                        });
                    })
                    .seq(function (cb) {
                        self.$endPoints.shutdown(function () {
                            // ignore errors during shutdown
                            cb();
                        });
                    })
                    .exec(function (err) {
                        callback && callback(err);

                        process.stdin.end();
                    });
            }
774676
function task(callback) {
	// spawn phantomas process
	var child = phantomas(url, options, function(err, data, results) {
		callback(
			null, // pass null even in case of an error to continue async.series processing (issue #380)
			[err, results]
		);
	});

	child.on('progress', function(progress, inc) {
		if (bar) {
			bar.tick(inc);
		}
	});

	// pipe --verbose messages to stderr
	child.stderr.pipe(process.stderr);
}
785165
protected static function runCallback($callback, $args)
    {
        if (!is_array($args)) {
            $args = isset($args) ? array($args) : array();
        }
        return call_user_func_array($callback, $args);
    }
1124422
function (callback) {
        debug('');
        async.parallel([

          // prepare eventStore...
          function (callback) {
            debug('prepare eventStore...');

            self.eventStore.on('connect', function () {
              self.emit('connect');
            });

            self.eventStore.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.eventStore.init(callback);
          },

          // prepare aggregateLock...
          function (callback) {
            debug('prepare aggregateLock...');

            self.aggregateLock.on('connect', function () {
              self.emit('connect');
            });

            self.aggregateLock.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.aggregateLock.connect(callback);
          },

          // prepare commandBumper...
          function (callback) {
            if (!self.commandBumper) {
              return callback(null);
            }
            debug('prepare commandBumper...');

            self.commandBumper.on('connect', function () {
              self.emit('connect');
            });

            self.commandBumper.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.commandBumper.connect(callback);
          }
        ], callback);
      }
719011
def _execute_callback(async, callback):
    
    from furious.async import Async

    if not callback:
        return async.result.payload

    if isinstance(callback, Async):
        return callback.start()

    return callback()
577252
function runWebServerInProcess(rawConfig, serverConfig, emitter) {
  var server = require('./server.js');
  
  if (serverConfig.command == 'stop') {
    logger.info('stopping server');
    return server.stop();
  }
  
  var app = server.listen(rawConfig, serverConfig, function(err, newCommandName, newConfig, finalCallback) {
    if (err) { 
      logger.error("Error: " + err);
      if (callback) callback(err);
    } else {
      emitter.emit(newCommandName, newConfig, finalCallback);
    }
  });
}
604000
def execute_callback(callback, *args)
      (callback.arity == 2 ? callback.call(*args[0, 2]) : callback.call(*args)) if callback
    end
1234752
function run () {
  if (argv.file) {
    const models = require(argv.file)
    return validate(models)
  }

  const json = argv.model || argv.references
  if (json) {
    return validate(JSON.parse(json))
  }

  printUsage()
  process.exit(1)
}
683565
function run(desc, data, callback) {
    if (callback.length === 2) {
        callItAsync(desc, data, callback)
    } else {
        callItSync(desc, data, callback)
    }
}
1275141
function run() {
        var startTime = (new Date()).getTime();

        // parse the command line using the commander object
        processCommandLine();

        // leverage the middleware to initialize all our services, adapters, etc. (i.e. connect to mongo, etc.)
        mwServiceInit.init({ container: 'batch' })
            .then(function () {
                var app = pancakes.cook(casing.camelCase(commander.app) + 'Batch');
                return app.run(commander);
            })
            .then(function () {
                var endTime = (new Date()).getTime();
                var diffTime = (endTime - startTime) / 1000;
                log.info(commander.app + ' complete (' + diffTime + 's)');
                process.exit(0);
            })
            .catch(function (err) {
                log.error(err);
                process.exit(1);
            });
    }
539535
public function addMiddleware($callback)
    {
        $this->middlewares[] = function (Callable $next, Request $request, Response $response) use ($callback) {
            $container = Container::getInstance();
            $parameters = array_merge([
                "request"   => $request,
                "response"  => $response,
                "next"      => $next
            ], $request->getData());

            $container->call($callback, $parameters);
        };
    }
1237453
function(err, req, res, next) {

        function done(error) {
            log(req, util.format('middleware-end %s', name));
            next(error);
        }

        if (err && !errHandler) {
            log(req, util.format('skipped %s Hook is not for error handling', name));
            next(err);

        } else if (!err && errHandler) {
            log(req, util.format('skipped %s Hook is for error handling', name));
            next();

        } else {
            try {
                log(req, util.format('middleware-start %s', name));
                errHandler ? hook(err, req, res, done) : hook(req, res, done);
            } catch (err) {
                done(err);
            }

        }
    }
827500
function next(err, cb) {
    if (typeof err === 'function') {
      debug('pushed filter callback');
      cb = err;
      err = null;
    }
    if (typeof cb === "function") callbacks.push(cb);

    debug('call middleware index', index);
    var layer = stack[index++];

    // No more middlewares or early end.
    if (!layer || ended) {
      debug('middleware-s call done');
      fn = callbacks.pop();
      while (fn) {
        err = fn(err, ctx);
        if (err) break;
        fn = callbacks.pop();
      }
      if (out) return out(err, ctx);
      if (err) throw err;
      return;
    }

    // Check if middleware type matches or if it has no type.
    if (layer.type.length > 0 && layer.type.indexOf(type) < 0) {
      return next(err);
    }

    try {
      var arity = layer.handle.length;
      //if err, only execute error middlewares
      if (err) {
        //error middlewares have an arity of 3, the first
        //arg being the error
        if (arity === 3) {
          layer.handle(err, ctx, next);
        } else {
          next(err);
        }
      } else if (arity < 2) {
        layer.handle(ctx);
        if (!ended) next();
      } else if (arity < 3) {
        layer.handle(ctx, next);
      } else {
        next();
      }
    }
    catch (e) {
      next(e);
    }
  }