qwc-services / qwc-admin-gui

QWC Admin GUI
MIT License
1 stars 17 forks source link

Plugins not connecting #56

Closed netrebin closed 2 years ago

netrebin commented 2 years ago

Greetings!

I'm using qwc-docker service. Try to enable plugins (themes and config_editor) in tenantConfig.json

"name": "adminGui",
      "config": {
        "db_url": "postgresql:///?service=qwc_configdb",
        "config_generator_service_url": "http://qwc-config-service:9090",
        "totp_enabled": false,
        "user_info_fields": [],
        "proxy_url_whitelist": [],
        "proxy_timeout": 60,
        "plugins": ["themes", "config_editor"],
        "input_config_path": "/srv/qwc_service/config-in",
        "qwc2_path": "/qwc2/",
        "qgs_resources_path": "/data",
        "ogc_service_url": "/ows/"

Config_editor plugin is appear but I have message '[Errno 2] No such file or directory: '/srv/qwc_service/config-in/default/tenantConfig.json'' image Themes plugin doesn't work What am I doing wrong?

tpo commented 2 years ago

You need to attach the directory containing config-in/ to /srv/qwc_service/config-in/ that is you need to add that to the container's docker-compose configuration.

netrebin commented 1 year ago

You need to attach the directory containing config-in/ to /srv/qwc_service/config-in/ that is you need to add that to the container's docker-compose configuration. Thanks for the answer, but an error occurs when trying to save the result of editing the file (tenantConfig.json or config.json) image

I add permissions:

sudo chown -R 33:33 volumes/attachments
sudo chown -R 33:33 volumes/config
sudo chown -R 33:33 volumes/qgs-resources
sudo chown -R 33:33 volumes/qwc2/assets

docker-compose.yaml:

 qwc-admin-gui:
    restart: always
    image: sourcepole/qwc-admin-gui:v2022.09.15
    environment:
      <<: *qwc-service-variables
      # Don't enable JWT CSRF protection for admin gui, it conflicts with CSRF protection offered by Flask-WTF
      JWT_COOKIE_CSRF_PROTECT: 'False'
      USER_INFO_FIELDS: '[{"title": "Surname", "name": "surname", "type": "text", "required": true}, {"title": "First name", "name": "first_name", "type": "text", "required": true}, {"title": "Street", "name": "street", "type": "text"}, {"title": "ZIP", "name": "zip", "type": "text"}, {"title": "City", "name": "city", "type": "text"}]'
      #TOTP_ENABLED: 'False'
      GROUP_REGISTRATION_ENABLED: 'True'
      #IDLE_TIMEOUT: 600
      DEFAULT_LOCALE: 'en'
      MAIL_SUPPRESS_SEND: 'True'
      MAIL_DEFAULT_SENDER: 'from@example.com'
    # ports:
    #   - "127.0.0.1:5031:9090"
    volumes:
      - ./pg_service.conf:/srv/pg_service.conf:ro
      - ./volumes/config:/srv/qwc_service/config:ro
      # required by themes plugin:
      - ./volumes/config-in:/srv/qwc_service/config-in:ro
      - ./volumes/config:/srv/qwc_service/config-out
      - ./volumes/qwc2:/qwc2

Part of tenantConfig.json:

{
      "name": "adminGui",
      "config": {
        "db_url": "postgresql:///?service=qwc_configdb",
        "config_generator_service_url": "http://qwc-config-service:9090",
        "totp_enabled": false,
        "user_info_fields": [],
        "proxy_url_whitelist": [],
        "proxy_timeout": 60,
        "admin_gui_title": "Admins",
        "admin_gui_subtitle": "Generates",
        "plugins": ["config_editor", "themes"], 
        "input_config_path": "/srv/qwc_service/config-in",
        "qwc2_path": "/qwc2/",
        "qgs_resources_path": "/data",
        "ogc_service_url": "/ows/"
      }

But the Themes plugin is still not active

tpo commented 1 year ago

What's the output of this when you execute it inside the qwc-admin container?

for path in /srv /qwc_service /config-in /default; do fullpath=$fullpath$path; echo $fullpath; ls -ld $fullpath; done
ls -l /srv/qwc_service/config-in/default/tenantConfig.json
netrebin commented 1 year ago
deb_adm@debian:~/fnc_rice/qwc-docker$ docker exec -it qwc-docker_qwc-admin-gui_1 sh
/ # for path in /srv /qwc_service /config-in /default; do fullpath=$fullpath$path; echo $fullpath; ls -ld
 $fullpath; done
/srv
drwxr-xr-x    1 root     root          4096 Dec  6 10:32 /srv
/srv/qwc_service
drwxr-xr-x    1 root     root          4096 Dec  6 10:32 /srv/qwc_service
/srv/qwc_service/config-in
drwxr-xr-x    3 1001     1001          4096 Dec  6 09:01 /srv/qwc_service/config-in
/srv/qwc_service/config-in/default
drwxr-xr-x    3 1001     1001          4096 Dec  6 10:35 /srv/qwc_service/config-in/default
/ # 
/ # ls -l /srv/qwc_service/config-in/default/tenantConfig.json
-rw-r--r--    1 1001     1001         10777 Dec  6 10:35 /srv/qwc_service/config-in/default/tenantConfig.json
/ # 
tpo commented 1 year ago

UID/GID 1001 does not seem right. Can you do ps faux inside the qwc-admin-gui container?

netrebin commented 1 year ago
/ # ps faux
PID   USER     TIME  COMMAND
    1 xfs       0:01 uwsgi --http-socket :9090 --buffer-size 12288 --processes 1 --threads 4 --plugins p
    7 xfs       0:24 uwsgi --http-socket :9090 --buffer-size 12288 --processes 1 --threads 4 --plugins p
   56 root      0:00 sh
   67 root      0:00 ps faux
tpo commented 1 year ago

grep xfs /etc/passwd

netrebin commented 1 year ago

grep xfs /etc/passwd

xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin
tpo commented 1 year ago

Above you write:

sudo chown -R 33:33 volumes/attachments
sudo chown -R 33:33 volumes/config
sudo chown -R 33:33 volumes/qgs-resources
sudo chown -R 33:33 volumes/qwc2/assets

Looks like config-in is missing there?

netrebin commented 1 year ago

Yes it is. Add sudo chown -R 33:33 volumes/config-in Now works good. But Themes plugin is inactive

manisandro commented 1 year ago

Note that rather you can also change the UID/GID which runs the QWC services to match the user/group which owns the shared volumes on the host by setting SERVICE_UID and SERVICE_GID in docker-compose.yml under x-qwc-service-variables.

tpo commented 1 year ago

Wrt themes - did you have a look at the docu here: https://github.com/qwc-services/qwc-services.github.io/blob/c81542393bb86c6c2a22958087088641803ebc88/content/setup/services/qwc-map-viewer.md ?

manisandro commented 1 year ago

@tpo The themes plugin is unrelated to the map viewer

@netrebin Can you please post the full docker log output from a freshly started admin gui container?

netrebin commented 1 year ago

@manisandro

*** Starting uWSGI 2.0.19.1 (64bit) on [Tue Dec  6 17:45:58 2022] ***
compiled with version: 10.3.1 20210921 on 05 April 2021 18:18:03
os: Linux-5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18)
nodename: 356368ac1bd3
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /
detected binary path: /usr/sbin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 33
setuid() to 33
chdir() to /srv/qwc_service
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :9090 fd 3
Python version: 3.9.13 (main, Jul 26 2022, 13:12:30)  [GCC 10.3.1 20211027]
Python main interpreter initialized at 0x7f775c624c00
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 274112 bytes (267 KB) for 4 cores
*** Operational MODE: threaded ***
mounting server:app on /qwc_admin
WSGI app 0 (mountpoint='/qwc_admin') ready in 42 seconds on interpreter 0x7f775c624c00 pid: 1 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 8, cores: 4)
SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
goodbye to uWSGI.
*** Starting uWSGI 2.0.19.1 (64bit) on [Tue Dec  6 17:52:34 2022] ***
compiled with version: 10.3.1 20210921 on 05 April 2021 18:18:03
os: Linux-5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18)
nodename: 356368ac1bd3
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /
detected binary path: /usr/sbin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 33
setuid() to 33
chdir() to /srv/qwc_service
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :9090 fd 3
Python version: 3.9.13 (main, Jul 26 2022, 13:12:30)  [GCC 10.3.1 20211027]
Python main interpreter initialized at 0x7f4f63c49c00
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 274112 bytes (267 KB) for 4 cores
*** Operational MODE: threaded ***
mounting server:app on /qwc_admin
WSGI app 0 (mountpoint='/qwc_admin') ready in 1 seconds on interpreter 0x7f4f63c49c00 pid: 1 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 7, cores: 4)
[2022-12-06 17:53:31,171] WARNING in server: Could not load plugin themes: qgs_resources_path is not set or invalid
/usr/lib/python3.9/site-packages/qwc_services_core/config_models.py:195: SAWarning: Property registration_requests.user on mapped class registration_requests->registration_requests being replaced with new property registration_requests.user; the old property will be discarded
  RegistrationRequest.user = relationship(
/srv/qwc_service/./access_control.py:73: SAWarning: SELECT statement has a cartesian product between FROM element(s) "anon_2" and FROM element "qwc_config.roles".  Apply join condition(s) between each element to resolve.
  (admin_role, ), = session.query(query.exists())
[pid: 7|app: 0|req: 1/1] 172.24.0.20 () {44 vars in 1739 bytes} [Tue Dec  6 17:53:31 2022] GET /qwc_admin/ => generated 5904 bytes in 821 msecs (HTTP/1.0 200) 3 headers in 95 bytes (1 switches on core 0)
[pid: 7|app: 0|req: 2/2] 172.24.0.20 () {42 vars in 1622 bytes} [Tue Dec  6 17:53:31 2022] GET /qwc_admin/static/css/application.css => generated 0 bytes in 494 msecs (HTTP/1.0 304) 3 headers in 146 bytes (0 switches on core 1)

And here it is - could not load plugin themes: qgs_resources_path is not set or invalid

manisandro commented 1 year ago

AFAICS you have no volume mounted at /data so that warning is likely accurate.

netrebin commented 1 year ago

@manisandro mounted /data. Now works greate @tpo and @manisandro Thank you very much!