def Init(argv, options, root_path, appinfo):
 if (ARG_BACKENDS not in options):
  return
 backends_path = os.path.join(root_path, 'backends.yaml')
 if (not os.path.exists(backends_path)):
  backends = []
 else:
  backends_fh = open(backends_path)
  try:
   backend_info = backendinfo.LoadBackendInfo(backends_fh.read())
  finally:
   backends_fh.close()
  backends = backend_info.backends
 backend_set = set()
 for backend in backends:
  if (backend.name in backend_set):
   raise Error(('Duplicate backend: %s' % backend.name))
  if (backend.instances is None):
   backend.instances = 1
  elif (backend.instances > BACKEND_MAX_INSTANCES):
   raise Error('Maximum number of instances is %d', BACKEND_MAX_INSTANCES)
  backend_set.add(backend.name)
 process = _dev_process
 process.Init(appinfo, backends, options)
 if process.IsDefault():
  logging.info('Default process')
  return
 SetLogPrefix(process)
 if process.IsMaster():
  process.StartChildren(argv, options)
 process.InitBalanceSet()
 if process.IsMaster():
  options['require_indexes'] = False
 else:
  options['require_indexes'] = True
 options['clear_datastore'] = False
 options['clear_prospective_search'] = False

def Init ( argv , options , root_path , appinfo ) : if ( ARG_BACKENDS not in options ) : return backends_path = os . path . join ( root_path , 'backends.yaml' ) if ( not os . path . exists ( backends_path ) ) : backends = [ ] else : backends_fh = open ( backends_path ) try : backend_info = backendinfo . LoadBackendInfo ( backends_fh . read ( ) ) finally : backends_fh . close ( ) backends = backend_info . backends backend_set = set ( ) for backend in backends : if ( backend . name in backend_set ) : raise Error ( ( 'Duplicate backend: %s' % backend . name ) ) if ( backend . instances is None ) : backend . instances = 1 elif ( backend . instances > BACKEND_MAX_INSTANCES ) : raise Error ( 'Maximum number of instances is %d' , BACKEND_MAX_INSTANCES ) backend_set . add ( backend . name ) process = _dev_process process . Init ( appinfo , backends , options ) if process . IsDefault ( ) : logging . info ( 'Default process' ) return SetLogPrefix ( process ) if process . IsMaster ( ) : process . StartChildren ( argv , options ) process . InitBalanceSet ( ) if process . IsMaster ( ) : options [ 'require_indexes' ] = False else : options [ 'require_indexes' ] = True options [ 'clear_datastore' ] = False options [ 'clear_prospective_search' ] = False
run all required startup routines and initialization hooks .