py.lib
7:15fa2da6627d Browse Files
+ Смена сервера с gevent на waitress + Организация членораздельного информирования в случае отсутствия модуля waitress
1.1 --- a/pgAdmin4_server.py Sun Jan 13 19:40:27 2019 +0300 1.2 +++ b/pgAdmin4_server.py Sun Jan 20 22:24:08 2019 +0300 1.3 @@ -1,5 +1,5 @@ 1.4 # coding: utf-8 1.5 -# devel.a0fs.net: pgadmin.selfServerAsync - v0.1 by awgur $ 1.6 +# devel.a0fs.net: pgadmin.selfServer - v0.2 by awgur $ 1.7 1.8 ########################################################################## 1.9 # 1.10 @@ -10,10 +10,15 @@ 1.11 # 1.12 ########################################################################## 1.13 1.14 -from gevent import monkey; monkey.patch_all() 1.15 -from gevent.pywsgi import WSGIServer 1.16 import os 1.17 import sys 1.18 + 1.19 +try: 1.20 + import waitress 1.21 +except ImportError: 1.22 + sys.stderr.write('\n ERROR: You need to install weitress module to you python instance\n\n') 1.23 + sys.exit(1) 1.24 + 1.25 import logging 1.26 from logging.handlers import SysLogHandler 1.27 1.28 @@ -39,7 +44,6 @@ 1.29 builtins.SERVER_MODE = True 1.30 1.31 import config 1.32 -# Monkey Path Dumy pgAdmin CONFIG 1.33 config.DATA_DIR = os.getenv('DATA_DIR') or config.DATA_DIR 1.34 config.SQLITE_PATH = os.getenv('SQLITE_PATH') or os.path.join(config.DATA_DIR, 'pgadmin4.db') 1.35 config.SESSION_DB_PATH = os.path.join(config.DATA_DIR, 'sessions') 1.36 @@ -47,18 +51,17 @@ 1.37 config.TEST_SQLITE_PATH = os.path.join(config.DATA_DIR, 'test_pgadmin4.db') 1.38 config.LOG_FILE = os.path.join(config.DATA_DIR, 'pgadmin4.log') 1.39 1.40 - 1.41 # When running it as a WSGI application, directory for the configuration file 1.42 # must present. 1.43 if not os.path.exists(os.path.dirname(config.SQLITE_PATH)): 1.44 - raise Exception( 1.45 - """ 1.46 -Required configuration file is not present! 1.47 -Please run setup.py first!""" 1.48 - ) 1.49 + raise Exception( 1.50 + """ 1.51 + Required configuration file is not present! 1.52 + Please run setup.py first!""" 1.53 + ) 1.54 1.55 from pgAdmin4 import app as application 1.56 prepLogger() 1.57 log = logging.getLogger() 1.58 1.59 -WSGIServer(('0.0.0.0', 44000), application, log=log, error_log=log).serve_forever() 1.60 +waitress.serve(application, host='0.0.0.0', port=44000)