register myself as a app to app manager do it after connector init success
507448
function () {

	LOG.warn('appinfo sent to lobby:');
	LOG.warn(l_appinfo);
	
    // notify AppManager we're ready
    l_notifyLobby('SR_APP_READY', l_appinfo, 'SR_APP_READY_RES',
        function (event) {

            if (event.data.op === true)
                LOG.sys('SR_APP_READY returns ok', 'l_HandlerPool');
            else
                LOG.error('SR_APP_READY returns fail', 'l_HandlerPool');

			// call onDone if exists (but just once)
            if (l_onDone) {
				UTIL.safeCall(l_onDone);
				l_onDone = undefined;
			}			
        }
    );
}
265370
def init_app(self, app):
        
        self.app = app
        self.log = app.logger.getChild('compass')
        self.log.debug("Initializing compass integration")
        self.compass_path = self.app.config.get('COMPASS_PATH', 'compass')
        self.config_files = self.app.config.get('COMPASS_CONFIGS', None)
        self.requestcheck_debug_only = self.app.config.get(
                'COMPASS_REQUESTCHECK_DEBUG_ONLY', True)
        self.skip_mtime_check = self.app.config.get(
                'COMPASS_SKIP_MTIME_CHECK', False)
        self.debug_only = self.app.config.get(
                'COMPASS_DEBUG_ONLY', False)
        self.disabled = self.app.config.get('COMPASS_DISABLED', False)

        if not self.debug_only:
            self.compile()
        if (not self.debug_only) \
                and (not self.requestcheck_debug_only or self.app.debug):
            self.app.after_request(self.after_request)
282657
def init_app(self, app, database=None):
        """"""

        # Register application
        if not app:
            raise RuntimeError('Invalid application.')
        self.app = app
        if not hasattr(app, 'extensions'):
            app.extensions = {}
        app.extensions['peewee'] = self

        app.config.setdefault('PEEWEE_CONNECTION_PARAMS', {})
        app.config.setdefault('PEEWEE_DATABASE_URI', 'sqlite:///peewee.sqlite')
        app.config.setdefault('PEEWEE_MANUAL', False)
        app.config.setdefault('PEEWEE_MIGRATE_DIR', 'migrations')
        app.config.setdefault('PEEWEE_MIGRATE_TABLE', 'migratehistory')
        app.config.setdefault('PEEWEE_MODELS_CLASS', Model)
        app.config.setdefault('PEEWEE_MODELS_IGNORE', [])
        app.config.setdefault('PEEWEE_MODELS_MODULE', '')
        app.config.setdefault('PEEWEE_READ_SLAVES', '')
        app.config.setdefault('PEEWEE_USE_READ_SLAVES', True)

        # Initialize database
        params = app.config['PEEWEE_CONNECTION_PARAMS']
        database = database or app.config.get('PEEWEE_DATABASE_URI')
        if not database:
            raise RuntimeError('Invalid database.')
        database = get_database(database, **params)

        slaves = app.config['PEEWEE_READ_SLAVES']
        if isinstance(slaves, string_types):
            slaves = slaves.split(',')
        self.slaves = [get_database(slave, **params) for slave in slaves if slave]

        self.database.initialize(database)
        if self.database.database == ':memory:':
            app.config['PEEWEE_MANUAL'] = True

        if not app.config['PEEWEE_MANUAL']:
            app.before_request(self.connect)
            app.teardown_request(self.close)
625340
protected void initializeAdbConnection() {
    // Get a device bridge instance. Initialize, create and restart.
    try {
      AndroidDebugBridge.init(false);
    } catch (IllegalStateException e) {
      if (!shouldKeepAdbAlive) {
        log.log(
            Level.WARNING,
            "AndroidDebugBridge may have been already initialized at this point. It is OK to proceed.",
            e);
      }
    }

    bridge = AndroidDebugBridge.getBridge();

    if (bridge == null) {
      bridge = AndroidDebugBridge.createBridge(adbPath, false);
    }
    IDevice[] devices = bridge.getDevices();

    AndroidDebugBridge.addDeviceChangeListener(this);

    // Add the existing devices to the list of devices we are tracking.
    if (devices.length > 0) {
      for (int i = 0; i < devices.length; i++) {
        deviceConnected(devices[i]);
        log.info("my devices: " + devices[i].getAvdName());
      }
    } else {
      long timeout = System.currentTimeMillis() + 2000;
      while ((devices = bridge.getDevices()).length == 0 && System.currentTimeMillis() < timeout) {
        try {
          Thread.sleep(50);
        } catch (InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
      if (devices.length > 0) {
        for (int i = 0; i < devices.length; i++) {
          deviceConnected(devices[i]);
          log.info("my devices: " + devices[i].getAvdName());
        }
      }
    }

  }
662725
def init_app(self, app):
        
        if not hasattr(app, 'extensions'):
            app.extensions = {}

        service_name = app.config.get('GSSAPI_SERVICE_NAME', 'HTTP')
        hostname = app.config.get('GSSAPI_HOSTNAME', socket.getfqdn())
        principal = '{}@{}'.format(service_name, hostname)
        name = gssapi.Name(principal, gssapi.NameType.hostbased_service)

        app.extensions['gssapi'] = {
            'creds': gssapi.Credentials(name=name, usage='accept'),
        }
518275
def _init_app(self, app):
        
        for resource, urls, kwargs in self.resources:
            self._register_view(app, resource, *urls, **kwargs)
1225931
def init_app(self, app, **kwargs):
        
        self.app = app

        self._init_extension()

        self.app.before_request(self.check_implicit_rules)

        if kwargs.get('ensure_authorization', False):
            self.app.after_request(self.check_authorization)
1103340
def initialize(self, app: Flask, app_config):
        
        debug = app_config["debug"]
        port = app_config["http.port"]
        if debug:
            self.started_on_port = port
            app.run(host="0.0.0.0", debug=True, port=port)
        else:
            for port in range(port, port + 50):
                self.http_server = WSGIServer(('0.0.0.0', port), app)
                try:
                    self.http_server.start()
                except OSError:
                    # try next port
                    continue
                self.started_on_port = port
                break
521331
def make_connector(self, app=None, bind=None):
        """"""
        return _EngineConnector(self, self.get_app(app), bind)
936018
def register(cls, *args, **kwargs):
        """"""
        if cls.app is None:
            return register(*args, handler=cls, **kwargs)
        return cls.app.register(*args, handler=cls, **kwargs)
970392
def init_app(self, app):
        """"""
        # Ensure SECRET_KEY is set.
        SECRET_KEY = app.config.get('SECRET_KEY')

        if SECRET_KEY is None:
            app.config['SECRET_KEY'] = 'CHANGE_ME'
            warnings.warn(
                'Set configuration variable SECRET_KEY with random string',
                UserWarning)
534762
def _register_socket(s):
        '''
        
        '''
        queue_to_app = Queue()
        with _lock:
            ApplicationLayer._to_app[s._sockid()] = queue_to_app
        return ApplicationLayer._from_app, queue_to_app
970311
def init_app(self, app):
        
        self.init_config(app)

        # Install datetime helpers.
        app.jinja_env.filters.update(
            from_isodate=from_isodate,
            from_isodatetime=from_isodatetime,
            to_arrow=to_arrow,
            format_arrow=format_arrow,
        )

        if app.config['FORMATTER_BADGES_ENABLE']:
            from invenio_formatter.context_processors.badges import \
                badges_processor

            # Registration of context processors.
            app.context_processor(badges_processor)
            # Register blueprint.
            app.register_blueprint(create_badge_blueprint(
                app.config['FORMATTER_BADGES_ALLOWED_TITLES']))

        app.extensions['invenio-formatter'] = self
249470
def init_app(self, app, entry_point_group='invenio_celery.tasks',
                 **kwargs):
        """"""
        self.init_config(app)
        self.celery = FlaskCeleryExt(app).celery
        self.entry_point_group = entry_point_group
        app.extensions['invenio-celery'] = self
95504
def init_app(self, app):
        '''
        
        '''
        self.app = app
        if not hasattr(app, 'extensions'):
            app.extensions = {}
        app.extensions['plugin_manager'] = self
        self.reload()
733658
function startApplication(appName, appDirectory, appList, configStore, sessionStore) {

    let path = appDirectory + '/' + appList[appName] + '/';
    let commonPath = appDirectory + '/apps/common/';
    let config = configStore[appName].get();
    let commonJsDir = commonPath + '/js/';
    let controllerJsDir = path + '/public/js/';

    if (config.isDaemon || config.serverMode === 'api') {
        controllerJsDir = path + '/js/';
    }

    let schema = JSON.parse((readFile(path + '/schema.json') || readFile(commonPath + '/schema.json')).toString());

    let controllerPath = (config.controller || 'controller.js');
    let matches = controllerPath.match(/(.*?)([0-9A-Za-z_]*)\.js$/);
    let prefix = matches[1];
    let prop = matches[2];

    // TODO: Completely change how we do configurations
    config.nconf = configStore[appName]; // Global config
    config.configStore = configStore;

    return setUpInjectObjectTemplate(appName, config, schema)
        .then(buildAppConfigAndLoadTemplates.bind(this, appName, config, controllerJsDir, commonJsDir, sessionStore))
        .spread(finishDaemonIfNeeded.bind(this, config, prop, prefix, appName));
}
265372
def init_app(self, app):
        
        state = self.init_mail(app.config, app.debug, app.testing)

        # register extension with app
        app.extensions = getattr(app, 'extensions', {})
        app.extensions['mail'] = state
        return state