qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.04k stars 2.92k forks source link

[server] Unloading of projects by QGIS Server (F)CGI instance #43771

Open andreassteffens opened 3 years ago

andreassteffens commented 3 years ago

Occasionally the need arises to update datasources such as shapefiles, SpatiaLite or GeoPackage DBs referenced by a project that is loaded in an active QGIS Server (F)CGI instance. Since the datasources cannot be overriden while in use the only currently available solution is to shutdown the parent webserver hosting the QGIS Server (F)CGI instance, update/replace the datasources and fire up the webserver again. In this scenario all projects hosted by the QGIS Server will of course temporarily not be available and need to be initialized all over again after QGIS Server has been fired back up.

It would be great if projects could be unloaded through some kind of new request supported by QGIS server. The info that a project has been (marked) unloaded would of course need to be communicated to all QGIS Server (F)CGI instances and also be serialized to some kind of configuration file read upon startup, so new QGIS Server instances will also be informed about currently unloaded projects.

Maybe a possible solution could be as simple as a FileSystemWatcher sitting on a file containing project paths to unloaded projects and an additional "UnloadProject/ReloadProject" request handler that writes to this file. QGIS Server would need to check the list of unloaded projects before servicing a request and not load projects marked unloaded.

elpaso commented 3 years ago

The current implementation is that if a project file (filesystem based, not hosted on a network share) changes it will be removed from cached projects.

If you need more control a server python plugin will work just fine for this scenario.

yellow-sky commented 2 years ago

Hi, @elpaso.

Where I can see example of reload instance project cache from python server plugin? Thx

rldhont commented 2 years ago

Hi @yellow-sky,

We have wrote a plugin to flush QGIS Project file because on some file system, QGIS Server is not advertised of changes. https://github.com/3liz/qgis-logging-plugin . You will find in this QGIS Server plugin a flush filter https://github.com/3liz/qgis-logging-plugin/blob/master/qgis_logger/flushfilter.py

You can also be interested in Py-QGIS-Server https://github.com/3liz/py-qgis-server

yellow-sky commented 2 years ago

Hi, @rldhont! It's cool! Thank you very much!