3
3
import shutil
4
4
import pwd
5
5
import getpass
6
+ import site
6
7
7
8
logging .basicConfig (level = "INFO" )
8
9
logger = logging .getLogger ("pgadmin" )
@@ -24,7 +25,7 @@ def _get_env(port, base_url):
24
25
25
26
default_email = os .
getenv (
"PGADMIN_DEFAULT_EMAIL" ,
"[email protected] " )
26
27
setup_email = os .
getenv (
"PGADMIN_SETUP_EMAIL" ,
"[email protected] " )
27
- return {
28
+ return {
28
29
"PGADMIN_SERVER_MODE" : 'True' ,
29
30
"PGADMIN_DEFAULT_EMAIL" : default_email ,
30
31
"PGADMIN_SETUP_EMAIL" : setup_email ,
@@ -57,7 +58,7 @@ def run_app():
57
58
This method is run by jupyter-server-proxy package to launch the Web app.
58
59
"""
59
60
60
- logger .info ("Initializing Jupyter pgadmin Proxy" )
61
+ logger .info ("Initializing Jupyter pgAdmin Proxy" )
61
62
62
63
icon_path = get_icon_path ()
63
64
try :
@@ -66,20 +67,31 @@ def run_app():
66
67
executable_name = "pgadmin4"
67
68
host = "127.0.0.1"
68
69
user = get_system_user ()
70
+ try :
71
+ chdir_path = f"{ site .getsitepackages ()[0 ]} /pgadmin4"
72
+ if not os .path .exists (chdir_path ):
73
+ chdir_path = os .path .dirname (os .path .abspath (__file__ ))
74
+ except Exception :
75
+ chdir_path = "/"
69
76
logger .debug (f"[{ user } ] Icon_path: { icon_path } " )
70
77
logger .debug (f"[{ user } ] Launch Command: { executable_name } " )
71
78
return {
72
79
"command" : [
73
- executable_name ,
74
- f"--host={ host } " ,
75
- "--listen={port}" ,
76
- "--debug" ,
77
- "--sessions" ,
80
+ # executable_name,
81
+ "uwsgi" ,
82
+ "--http-socket" , "127.0.0.1:{port}" ,
83
+ "--mount" , "{base_url}pgadmin4/=pgAdmin4:app" ,
84
+ "--chdir" , chdir_path ,
85
+ "--manage-script-name" ,
86
+ "--processes" , "1" ,
87
+ "--threads" , "25" ,
88
+ "--need-app" ,
78
89
],
79
- "timeout" : 100 ,
90
+ "timeout" : 300 ,
80
91
"environment" : _get_env ,
81
92
"absolute_url" : True ,
82
93
# "rewrite_response": rewrite_netloc,
94
+ # "request_headers_override": {"X-Script-Name": "{base_url}pgadmin4/"},
83
95
"launcher_entry" : {
84
96
"title" : "pgAdmin4" ,
85
97
"icon_path" : icon_path
0 commit comments