Repository URL to install this package:
| 
      
        
        
        Version: 
        
         
          
          4.1.94.1.dev2  ▾
        
         | 
# Copyright 2018 TrilioData Inc.
# All Rights Reserved.
"""
   Starter script for DM API.
"""
import sys
from oslo_log import log as logging
from oslo_reports import guru_meditation_report as gmr
from oslo_reports import opts as gmr_opts
import multiprocessing as mp
import dmapi.conf
from dmapi import config
from dmapi import exception
from dmapi import service
from dmapi import utils
from dmapi import version
CONF = dmapi.conf.CONF
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "dmapi")
    utils.monkey_patch()
    gmr_opts.set_defaults(CONF)
    log = logging.getLogger(__name__)
    gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
    launcher = service.process_launcher()
    started = 0
    for api in CONF.dmapi_enabled_apis:
        should_use_ssl = api in CONF.dmapi_enabled_ssl_apis
        try:
            server = service.WSGIService(api, use_ssl=should_use_ssl)
            try:
                launcher.launch_service(server, workers=server.workers)
            except Exception as worker_ex:
                log.warning('{0}, could not found dmapi_workers in conf file, setting dmapi workers to the available cores{1}.'.format(worker_ex, mp.cpu_count()))
                launcher.launch_service(server, workers=mp.cpu_count())
            started += 1
        except exception.PasteAppNotFound as ex:
            log.warning("%s. ``dmapi_enabled_apis`` includes bad values. "
                        "Fix to remove this warning.", ex)
    if started == 0:
        log.error('No APIs were started. '
                  'Check the dmapi_enabled_apis config option.')
        sys.exit(1)
    launcher.wait()