3liz / py-qgis-server

QGIS embbeded WMS/WFS/WCS asynchronous scalable http server
https://docs.3liz.org/py-qgis-server
Mozilla Public License 2.0
68 stars 16 forks source link

running proxy and workers with docker #36

Closed lassitanskanen closed 2 years ago

lassitanskanen commented 2 years ago

Hi,

Thanks for this repo! The examples is working fine but I didn't manage to run proxy and workers separately. I got some errors with these commands:

docker run -p 8080:8080 --name=qgis-proxy -e QGSRV_USER=$(id -u) -e QGSRV_LOGGING_LEVEL=DEBUG 3liz/qgis-map-server:3.22 qgisserver-proxy

Traceback (most recent call last): File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/runtime.py", line 318, in run_server worker_pool.start_supervisor() AttributeError: 'NoneType' object has no attribute 'start_supervisor' Terminating child processes 2022-03-15 07:19:47,448 INFO [1] Terminating client b'OWS-SERVER-1' PID 1: Server instance stopped Traceback (most recent call last): File "/usr/local/bin/qgisserver", line 8, in sys.exit(main()) File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/server.py", line 109, in main run_server( port=args.port, address=args.interfaces, jobs=args.jobs, user=args.setuid, workers=workers ) File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/runtime.py", line 361, in run_server if cache_observer: UnboundLocalError: local variable 'cache_observer' referenced before assignment


docker run -v $(pwd)/QGIS-Sample-Data/qgis_sample_data/projects:/projects \ --name qgis-worker \ -e QGSRV_CACHE_ROOTDIR=/projects \ -e QGSRV_USER=$(id -u) \ -e QGSRV_LOGGING_LEVEL=DEBUG \ -e ROUTER_HOST=qgis-proxy \ 3liz/qgis-map-server:3.22 qgisserver-worker

2022-03-15 07:21:56,571 DEBUG [1] Qgis: Server: Server initialized 2022-03-15 07:21:56,573 INFO [1] Proxy configuration enabled: :0, type: DefaultProxy 2022-03-15 07:21:56,573 DEBUG [1] Connecting to tcp://qgis-proxy:18080 2022-03-15 07:21:56,574 DEBUG [1] Identity set to b'\x98\x82\xdf8\xa40\x11\xec\xba\x90\x02B\xac\x11\x00\x03' 2022-03-15 07:21:56,574 DEBUG [1] Enabling broadcast notification Application state: QGIS_PREFIX_PATH env var: /usr Prefix: /usr Plugin Path: /usr/lib/qgis/plugins Package Data Path: /usr/share/qgis Active Theme Name: Active Theme Path: /usr/share/qgis/resources/themes//icons/ Default Theme Path: :/images/themes/default/ SVG Search Paths: /usr/share/qgis/svg/ User DB Path: /usr/share/qgis/resources/qgis.db Auth DB Path: qgis-auth.db

Traceback (most recent call last): File "/usr/local/bin/qgisserver-worker", line 8, in sys.exit(main()) File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/qgsworker.py", line 500, in main QgsRequestHandler.run(args.router.format(host=args.host), identity=args.identity, File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/qgsworker.py", line 335, in run run_worker(router, QgsRequestHandler, identity=bytes(identity.encode('ascii')), File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/zeromq/worker.py", line 153, in run_worker supervisor = SupervisorClient() File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/zeromq/supervisor.py", line 43, in init address = _get_ipc('supervisor') File "/opt/local/pyqgisserver/lib/python3.8/site-packages/pyqgisserver/zeromq/utils.py", line 5, in _get_ipc ipc_path = confservice['zmq']['ipcpath'] File "/usr/lib/python3.8/configparser.py", line 1254, in getitem raise KeyError(key) KeyError: 'ipcpath'

dmarteau commented 2 years ago

Hi,

This option has should be considered as drepecated and is not really maintained ATM.

Running the server this way prevents supervising workers in a effective way and has is not efficient from a caching point of view. Also, it has almost no interest when running in a single machine.

A better and more effective alternative is to use a reverse proxy for load balancing and sharding between pool of projects in case of many projects. (see discussion https://github.com/3liz/py-qgis-server/issues/10#issuecomment-639437713)

dmarteau commented 2 years ago

The server/proxy configuration has been fixed. It was broken since worker supervision was implemented.

cf b2eea044