def main(): # Load the config config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_object('cacahuate.settings') config.from_envvar('CACAHUATE_SETTINGS', silent=True) # Set the timezone os.environ['TZ'] = config['TIMEZONE'] time.tzset() # Setup logging logging.config.dictConfig(config['LOGGING']) # Load the models eng = Engine( host=config['REDIS_HOST'], port=config['REDIS_PORT'], db=config['REDIS_DB'], id_function=yuid, ) bind_models(eng) # Create mongo indexes create_indexes(config) # start the loop loop = Loop(config) loop.start()
def init_config(config: Config) -> None: """Load config""" env_flask_config_name = os.getenv('FLASK_CONFIG') or 'development' flask_config_name = f'config.{env_flask_config_name}.json' config.from_object(DefaultConfig()) config.from_json( os.path.normpath( os.path.join(os.path.dirname(__file__), flask_config_name))) config.from_envvar('SQLALCHEMY_DATABASE_URI', True) config.from_envvar('APP_VERSION', True) config.from_envvar('SERVER_NAME', True)
def run(): config = Config() config.from_object('configs.default') setup_logging(config) setup_database(config.get('DB_PATH')) setup_items(config.get('ITEMS_CONF')) backend_app = backend.build(**config) backend_app.run() frontend_app = frontend.build(**config) frontend_app.run() tornado.ioloop.IOLoop.instance().start()
def main(): # Load the config config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_object('cacahuate.settings') if os.getenv('CACAHUATE_SETTINGS'): config.from_envvar('CACAHUATE_SETTINGS', silent=False) # Set the timezone os.environ['TZ'] = config['TIMEZONE'] time.tzset() # Setup logging logging.config.dictConfig(config['LOGGING']) # Load the models eng = Engine( host=config['REDIS_HOST'], port=config['REDIS_PORT'], db=config['REDIS_DB'], id_function=getattr( import_module(config['DB_ID_FUNCTION'].rsplit('.', 1)[0]), config['DB_ID_FUNCTION'].rsplit('.', 1)[1], ), ) bind_models(eng) # Create mongo indexes create_indexes(config) # Update celery config celery.conf.update( broker='amqp://{user}@{host}//'.format( user=config['RABBIT_USER'], host=config['RABBIT_HOST'], ), worker_concurrency=1, worker_hijack_root_logger=False, task_default_queue=config['RABBIT_QUEUE'], ) worker = celery.Worker() worker.start()
from flask import config as flask_conf import os import logging.config import sys # by laziness we use flask config manager since it is the best we know config = flask_conf.Config(os.path.dirname(os.path.realpath(__file__))) config.from_object('artemis.default_settings') if 'CONFIG_FILE' in os.environ: config.from_envvar('CONFIG_FILE') if 'LOGGER' in config: logging.config.dictConfig(config['LOGGER']) else: # Default is std out handler = logging.StreamHandler(stream=sys.stdout) log = logging.getLogger(__name__) log.setLevel('INFO') log.addHandler(handler)
from flask import config as flask_conf import os import logging.config import sys # by laziness we use flask config manager since it is the best we know config = flask_conf.Config(os.path.dirname(os.path.realpath(__file__))) config.from_object("artemis.default_settings") if "CONFIG_FILE" in os.environ: config.from_envvar("CONFIG_FILE") if "LOGGER" in config: logging.config.dictConfig(config["LOGGER"]) else: # Default is std out handler = logging.StreamHandler(stream=sys.stdout) log = logging.getLogger(__name__) log.setLevel("INFO") log.addHandler(handler)