diff --git a/main.py b/main.py index cf6dfc4..408473e 100644 --- a/main.py +++ b/main.py @@ -70,6 +70,15 @@ app.config['LDAP_GROUP_OBJECT_FILTER'] = '(objectclass=posixGroup)' app.config['LDAP_BIND_USER_DN'] = None app.config['LDAP_BIND_USER_PASSWORD'] = None +# stop db restarts from causing stales and client-side 'server errors' - its a +# touch hacky, e.g. it issues a select 1 before EVERY request, likely should +# ditch this and just have a short-lived pool, but need to work out if/where I +# can catch the right exception myself and then dont need this, but for now... +app.config['SQLALCHEMY_ENGINE_OPTIONS'] = { + "pool_pre_ping": True, + "pool_recycle": 280, # Good practice to include this with pre-ping +} + db = SQLAlchemy(app) # create the (flask) sqlalchemy connection ma = Marshmallow(app) # set up Marshmallow - data marshalling / serialising