def setup_app(config): models.init_model() app_conf = dict(config.app) return make_app( app_conf.pop('root'), logging=getattr(config, 'logging', {}), **app_conf )
def reload_config(): from pecan import configuration config = configuration.conf_from_file(config_file()).to_dict() # Add the appropriate connection string to the app config. config['sqlalchemy'] = { 'url': '%s/%s' % (BIND, DBNAME), 'encoding': 'utf-8', 'poolclass': NullPool } configuration.set_config(config, overwrite=True) _db.init_model()
def bootstrap_pecan(signal, sender): try: config_path = os.environ['PECAN_CONFIG'] except KeyError: here = os.path.abspath(os.path.dirname(__file__)) # XXX this will not hold true when installing as a binary config_path = os.path.abspath(os.path.join(here, '../config/config.py')) pecan.configuration.set_config(config_path, overwrite=True) configure_celery_logging() # Once configuration is set we need to initialize the models so that we can connect # to the DB wth a configured mapper. models.init_model()
def setup_app(config): models.init_model() app_conf = dict(config.app) app = make_app(app_conf.pop('root'), logging=getattr(config, 'logging', {}), **app_conf) # make a series of health checks, post if they are good asynch.post_if_healthy() return app
def setup_app(config): models.init_model() app_conf = dict(config.app) app = make_app( app_conf.pop('root'), logging=getattr(config, 'logging', {}), **app_conf ) # make a series of health checks, post if they are good async.post_if_healthy() return app
def reload_config(): from pecan import configuration config = configuration.conf_from_file(config_file()).to_dict() # Add the appropriate connection string to the app config. config['sqlalchemy'] = { 'url': '%s/%s' % (BIND, DBNAME), 'encoding': 'utf-8', 'poolclass': NullPool } configuration.set_config( config, overwrite=True ) _db.init_model()
try: os.environ['PECAN_CONFIG'] except KeyError: here = os.path.abspath(os.path.dirname(__file__)) config_path = os.path.abspath(os.path.join(here, '../config/config.py')) return config_path pecan.configuration.set_config(get_pecan_config(), overwrite=True) # FIXME: this needs to be configurable. Also, not sure if this is the right way # to configure Celery for multiple tasks running in a single service. # TODO: Investigate if this could be `chacra.async.rpm` and # `chacra.async.debian` or if it doesn't matter app = Celery('chacra.async', broker='amqp://guest@localhost//') models.init_model() class SQLATask(celery.Task): """ An abstract Celery Task that ensures that the connection the the database is closed on task completion .. note:: On logs, it may appear as there are errors in the transaction but this is not an error condition: SQLAlchemy rolls back the transaction if no change was done. """ abstract = True def after_return(self, status, retval, task_id, args, kwargs, einfo): models.clear()