Skip to content

Commit b5c2854

Browse files
authored
run pgadmin with uwsgi
1 parent d409456 commit b5c2854

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/jupyter_pgadmin_proxy/__init__.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import pwd
55
import getpass
6+
import site
67

78
logging.basicConfig(level="INFO")
89
logger = logging.getLogger("pgadmin")
@@ -24,7 +25,7 @@ def _get_env(port, base_url):
2425

2526
default_email = os.getenv("PGADMIN_DEFAULT_EMAIL", "[email protected]")
2627
setup_email = os.getenv("PGADMIN_SETUP_EMAIL", "[email protected]")
27-
return {
28+
return {
2829
"PGADMIN_SERVER_MODE": 'True',
2930
"PGADMIN_DEFAULT_EMAIL": default_email,
3031
"PGADMIN_SETUP_EMAIL": setup_email,
@@ -57,7 +58,7 @@ def run_app():
5758
This method is run by jupyter-server-proxy package to launch the Web app.
5859
"""
5960

60-
logger.info("Initializing Jupyter pgadmin Proxy")
61+
logger.info("Initializing Jupyter pgAdmin Proxy")
6162

6263
icon_path = get_icon_path()
6364
try:
@@ -66,20 +67,31 @@ def run_app():
6667
executable_name = "pgadmin4"
6768
host = "127.0.0.1"
6869
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 = "/"
6976
logger.debug(f"[{user}] Icon_path: {icon_path}")
7077
logger.debug(f"[{user}] Launch Command: {executable_name}")
7178
return {
7279
"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",
7889
],
79-
"timeout": 100,
90+
"timeout": 300,
8091
"environment": _get_env,
8192
"absolute_url": True,
8293
# "rewrite_response": rewrite_netloc,
94+
# "request_headers_override": {"X-Script-Name": "{base_url}pgadmin4/"},
8395
"launcher_entry": {
8496
"title": "pgAdmin4",
8597
"icon_path": icon_path

0 commit comments

Comments
 (0)