From b1875f5834a3509a5919db59f2c0d968856308a5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 3 Mar 2019 13:10:08 -0600 Subject: [PATCH] Add support for simple postgres restart --- rattail_demo/web/app.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rattail_demo/web/app.py b/rattail_demo/web/app.py index 26858dc..bfcb7a7 100644 --- a/rattail_demo/web/app.py +++ b/rattail_demo/web/app.py @@ -14,13 +14,13 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ - # set some defaults for postgres - app.provide_postgresql_settings(settings) - # prefer demo templates over tailbone settings.setdefault('mako.directories', ['rattail_demo.web:templates', 'tailbone:templates',]) + # for graceful handling of postgres restart + settings.setdefault('retry.attempts', 2) + # make config objects rattail_config = app.make_rattail_config(settings) pyramid_config = app.make_pyramid_config(settings) @@ -34,4 +34,8 @@ def main(global_config, **settings): pyramid_config.include('rattail_demo.web.subscribers') pyramid_config.include('rattail_demo.web.views') + # for graceful handling of postgres restart + pyramid_config.add_tween('tailbone.tweens.sqlerror_tween_factory', + under='pyramid_tm.tm_tween_factory') + return pyramid_config.make_wsgi_app()