diff --git a/webnotes/app.py b/webnotes/app.py
index a6de33b0d1..f30f5d830b 100644
--- a/webnotes/app.py
+++ b/webnotes/app.py
@@ -20,6 +20,19 @@ import webnotes.webutils
local_manager = LocalManager([webnotes.local])
+def handle_session_stopped():
+ res = Response("""
+
+
+ Updating.
+ We will be back in a few moments...
+
+
+ """)
+ res.status_code = 503
+ res.content_type = 'text/html'
+ return res
+
@Request.application
def application(request):
webnotes.local.request = request
@@ -46,25 +59,29 @@ def application(request):
except HTTPException, e:
return e
+ except webnotes.SessionStopped, e:
+ webnotes.local._response = handle_session_stopped()
+
finally:
if webnotes.conn:
webnotes.conn.close()
- return webnotes._response
+ return webnotes.local._response
application = local_manager.make_middleware(application)
-
-application = StaticDataMiddleware(application, {
- '/': 'public',
-})
-
+if not os.environ.get('NO_STATICS'):
+ application = StaticDataMiddleware(application, {
+ '/': 'public',
+ })
def serve(port=8000, profile=False):
webnotes.validate_versions()
global application
from werkzeug.serving import run_simple
+
if profile:
application = ProfilerMiddleware(application)
+
run_simple('0.0.0.0', int(port), application, use_reloader=True,
use_debugger=True, use_evalex=True)