Sporadically crashes on Windows when exit. Fixes #3177

1) Shutdown the python server properly.
  2) Disabled "Shutdown server" menu till server is not successfully started.

Initial patch sent by Maxim, modified by Akshay Joshi.
This commit is contained in:
Maxim Zakharov
2018-03-15 13:26:24 +05:30
committed by Akshay Joshi
parent 3c4359270e
commit 54b1a79cb6
7 changed files with 91 additions and 1 deletions

View File

@@ -10,7 +10,7 @@
"""A blueprint module providing utility functions for the application."""
import pgadmin.utils.driver as driver
from flask import url_for, render_template, Response
from flask import url_for, render_template, Response, request
from flask_babel import gettext
from pgadmin.utils import PgAdminModule
from pgadmin.utils.preferences import Preferences
@@ -116,3 +116,17 @@ def explain_js():
status=200,
mimetype="application/javascript"
)
##########################################################################
# A special URL used to shutdown the server
##########################################################################
@blueprint.route("/shutdown", methods=('get', 'post'))
def shutdown():
if config.SERVER_MODE is not True:
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
return 'SHUTDOWN'
else:
return ''