RE: Consider default SERVER_MODE =True for pgadmin4-v1-web

From: Mike Surcouf <mikes(at)surcouf(dot)co(dot)uk>
To: 'Dave Page' <dpage(at)pgadmin(dot)org>
Cc: "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: RE: Consider default SERVER_MODE =True for pgadmin4-v1-web
Date: 2017-07-19 16:13:42
Message-ID: 2197768425D7F5479A0FFB3FEC212F7FF5F00DA0@aesmail.surcouf.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Here is my setup script for pgadmin in server mode on Centos 7 using the docs as a base.

It may or may not be useful

----------------------------------------------------------
#Install pgadmin
yum -y install pgadmin4-v1-web
yum -y install python-passlib

#Create user for pgadmin
useradd --create-home --home-dir /var/pgadmin --system --shell /sbin/nologin pgadmin
#Allow apache access to the pgadmin home directory
semanage fcontext -a -t httpd_sys_rw_content_t "/var/pgadmin(/.*)?"
restorecon -R /var/pgadmin

#Allow pgadmin to connect to postgres
setsebool -P httpd_can_network_connect_db 1

#Overide SERVER_MODE (must be done BEFORE setup)
cat >> /usr/lib/python2.7/site-packages/pgadmin4-web/config_local.py << "EOF"
SERVER_MODE = True
EOF

#Add default username and password and setup database
su -s /bin/sh -c 'python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py' pgadmin

#Add apache configuration
cat >> /etc/httpd/conf.d/pgadmin4-v1.conf << "EOF"
CustomLog "logs/pgadmin-access_log" combined
ErrorLog "logs/pgadmin-error_log"
LogLevel error

WSGIDaemonProcess pgadmin processes=1 threads=25 user=pgadmin group=pgadmin
WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

<Directory /usr/lib/python2.7/site-packages/pgadmin4-web>
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
EOF

#Open firewall for pgadmin
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --reload

#Start apache
systemctl enable httpd.service
systemctl start httpd.service
----------------------------------

From: Dave Page [mailto:dpage(at)pgadmin(dot)org]
Sent: 19 July 2017 17:03
To: Mike Surcouf
Cc: pgadmin-support(at)postgresql(dot)org
Subject: Re: Consider default SERVER_MODE =True for pgadmin4-v1-web

On Wed, Jul 19, 2017 at 4:54 PM, Mike Surcouf <mikes(at)surcouf(dot)co(dot)uk<mailto:mikes(at)surcouf(dot)co(dot)uk>> wrote:
It would be nice if the pgadmin40v1-web package set the SERVER_MODE = True

I can't think why you would install the web package without this but there may be a reason?

Yes, it would break the default installation mode (desktop).

The web package is "the web components of pgadmin", not "pgadmin to run in web mode".

Also since the setup script does different things depending on this value if you don't do it first you have to delete the config and sqllite database and start again otherwise it will never work

Currently I have this in my setup script

#Overide SERVER_MODE (must be done BEFORE setup)
cat >> /usr/lib/python2.7/site-packages/pgadmin4-web/config_local.py << "EOF"
SERVER_MODE = True
EOF

I tend to just edit that setting in config_local.py as I need it, but then also include:

# Use a different config DB for each server mode.
if SERVER_MODE == False:
SQLITE_PATH = os.path.join(
DATA_DIR,
'pgadmin4-desktop.db'
)
else:
SQLITE_PATH = os.path.join(
DATA_DIR,
'pgadmin4-server.db'
)

Anyway, to the main point - I've been trying to figure out a half-decent way of being able to support both server and desktop modes out of the box; and have yet to come up with anything that wouldn't be a tangled mess of config files. I still have some ideas though, and hope to explore them some more tomorrow.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Dave Page 2017-07-19 16:23:50 Re: Consider default SERVER_MODE =True for pgadmin4-v1-web
Previous Message Mike Surcouf 2017-07-19 16:07:02 RE: Consider default SERVER_MODE =True for pgadmin4-v1-web