'Load plugins, database, and config. Also initializes (but does not start) the task queue and ipc server.
This should only be called after obtaining a lock.'

def initialize(self):

    if self.initialized:
        raise RuntimeError(u'Cannot    call    initialize    on    an    already    initialized    manager.')
    plugin.load_plugins(extra_dirs=[os.path.join(self.config_base, u'plugins')])
    if (not self.args):
        self.args = [u'--help']
    self.options = get_parser().parse_args(self.args)
    self.task_queue = TaskQueue()
    self.ipc_server = IPCServer(self, self.options.ipc_port)
    self.setup_yaml()
    self.init_sqlalchemy()
    fire_event(u'manager.initialize', self)
    try:
        self.load_config()
    except ValueError as e:
        log.critical((u'Failed    to    load    config    file:    %s' % e.args[0]))
        raise
    from flexget.utils.simple_persistence import SimplePersistence
    self.persist = SimplePersistence(u'manager')
    if db_schema.upgrade_required():
        log.info(u'Database    upgrade    is    required.    Attempting    now.')
        fire_event(u'manager.upgrade', self)
        if manager.db_upgraded:
            fire_event(u'manager.db_upgraded', self)
    fire_event(u'manager.startup', self)
    self.initialized = True
