コード例 #1
0
def init_sentry_sdk():
    if settings.IS_DEV:
        return
    # pylint: disable=abstract-class-instantiated
    sentry_sdk.init(
        dsn=settings.SENTRY_DSN,
        integrations=[
            FlaskIntegration(),
            RedisIntegration(),
            RqIntegration(),
            SqlalchemyIntegration()
        ],
        release=read_version_from_file(),
        environment=settings.ENV,
        traces_sample_rate=settings.SENTRY_SAMPLE_RATE,
    )
コード例 #2
0
ファイル: worker.py プロジェクト: ragekit75/pass-culture-api
if __name__ == "__main__":
    listen = sys.argv[1:] or ["default"]
    logger.info("Worker: listening to queues %s", listen)

    log_redis_connection_status()
    log_database_connection_status()

    if settings.IS_DEV is False:
        sentry_sdk.init(
            dsn=settings.SENTRY_DSN,
            integrations=[
                RedisIntegration(),
                RqIntegration(),
                SqlalchemyIntegration()
            ],
            release=read_version_from_file(),
            environment=settings.ENV,
            traces_sample_rate=settings.SENTRY_SAMPLE_RATE,
        )
        logger.info("Worker : connection to sentry OK")

    while True:
        try:
            with app.app_context():
                # This sessions removals are meant to prevent open db connection
                # to spread through forked children and cause bugs in the jobs
                # https://python-rq.org/docs/workers/#the-worker-lifecycle
                # https://docs.sqlalchemy.org/en/13/core/connections.html?highlight=dispose#engine-disposal
                db.session.remove()
                db.session.close()
                db.engine.dispose()
コード例 #3
0
def health_api():
    output = read_version_from_file()
    return output, 200
コード例 #4
0
def health_database():
    database_working = check_database_connection()
    return_code = 200 if database_working else 500
    output = read_version_from_file()
    return output, return_code