py.lib
6:8c951e942fee
Go to Latest
py.lib/pgAdmin4_server.py
+ Управляем ещё и логами
2 # devel.a0fs.net: pgadmin.selfServerAsync - v0.1 by awgur $
4 ##########################################################################
6 # pgAdmin 4 - PostgreSQL Tools
8 # Copyright (C) 2013 - 2018, The pgAdmin Development Team
9 # This software is released under the PostgreSQL Licence
11 ##########################################################################
13 from gevent import monkey; monkey.patch_all()
14 from gevent.pywsgi import WSGIServer
18 from logging.handlers import SysLogHandler
22 _format = 'lo.ad.pgadmin[%(process)d]: %(message)s'
23 _logHandler = SysLogHandler(address='/dev/log', facility='user')
24 _logHandler.setFormatter(logging.Formatter(_format))
25 logging.basicConfig(level=logging.INFO)
26 _log = logging.getLogger()
27 _log.handlers = [_logHandler,]
29 root = os.path.dirname(os.path.realpath(__file__))
30 if sys.path[0] != root:
31 sys.path.insert(0, root)
33 if sys.version_info[0] >= 3:
36 import __builtin__ as builtins
38 # Ensure the global server mode is set.
39 builtins.SERVER_MODE = True
42 # Monkey Path Dumy pgAdmin CONFIG
43 config.DATA_DIR = os.getenv('DATA_DIR') or config.DATA_DIR
44 config.SQLITE_PATH = os.getenv('SQLITE_PATH') or os.path.join(config.DATA_DIR, 'pgadmin4.db')
45 config.SESSION_DB_PATH = os.path.join(config.DATA_DIR, 'sessions')
46 config.STORAGE_DIR = os.path.join(config.DATA_DIR, 'storage')
47 config.TEST_SQLITE_PATH = os.path.join(config.DATA_DIR, 'test_pgadmin4.db')
48 config.LOG_FILE = os.path.join(config.DATA_DIR, 'pgadmin4.log')
51 # When running it as a WSGI application, directory for the configuration file
53 if not os.path.exists(os.path.dirname(config.SQLITE_PATH)):
56 Required configuration file is not present!
57 Please run setup.py first!"""
60 from pgAdmin4 import app as application
62 log = logging.getLogger()
64 WSGIServer(('0.0.0.0', 44000), application, log=log, error_log=log).serve_forever()