Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f5c5184
Initial work to remove the DbServer
micheles Sep 11, 2026
c063d38
Finally removed the DbServer
micheles Sep 11, 2026
0ca1f86
Cleanup
micheles Sep 11, 2026
4435de8
Restored openquake.cfg
micheles Sep 11, 2026
2cf5094
Merge branch 'port-more' into dbserver
micheles Sep 11, 2026
deb01a4
Fix duplicate FastAPI import
micheles Sep 11, 2026
a484561
Merge branch 'master' into dbserver
micheles Sep 11, 2026
0cbe5fc
Removed obsolete endpoints
micheles Sep 11, 2026
9d09575
Cleanup up tests
micheles Sep 11, 2026
f65300c
More cleanup
micheles Sep 11, 2026
a699335
Upgrading the db at WebUI start
micheles Sep 11, 2026
93f4044
Restored autocommit
micheles Sep 11, 2026
d987545
More cleanup
micheles Sep 11, 2026
a97fb4a
Restored impact_run_with_shakemap to Django
micheles Sep 11, 2026
25772f1
Removed duplication
micheles Sep 11, 2026
e16ee3d
Removed dbserver docs
micheles Sep 11, 2026
678c293
Fixed doc
micheles Sep 11, 2026
3e1a4dd
Removed more dbserver [ci skip]
micheles Sep 11, 2026
efa78ec
Fixed missing port
micheles Sep 11, 2026
357f19e
Fixed authkey and multi_user functionality
micheles Sep 14, 2026
8f421bd
Merge branch 'master' into dbserver
micheles Sep 14, 2026
ab18f46
Merge branch 'master' into dbserver
micheles Sep 14, 2026
d1d9b56
Added commands oq webui status|stop
micheles Sep 15, 2026
259820c
Skipped test on Windows
micheles Sep 15, 2026
e246040
Fixed test
micheles Sep 15, 2026
56610f9
Moved helpers inside api.py
micheles Sep 15, 2026
82ffcda
Merge branch 'master' into dbserver
micheles Sep 15, 2026
3c28ca0
Fixed windows test
micheles Sep 15, 2026
66e9b2c
Removed unnecessary run_in_threadpool
micheles Sep 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/upgrade_procedure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ jobs:
source /opt/openquake/venv/bin/activate
oq --version
deactivate
sudo systemctl stop openquake-dbserver
sleep 10
sudo env "PATH=$PATH" python install.py server --remove
sudo env "PATH=$PATH" python install.py server --version=master
source /opt/openquake/venv/bin/activate
journalctl -xe -u openquake-dbserver
sleep 5
oq --version
oq engine --run "https://github.com/gem/oq-engine/blob/master/openquake/server/tests/data/classical.zip?raw=true"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/windows_oldaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ jobs:
#
#python -c 'import fiona'
oq --version
Start-Job -ScriptBlock{& 'C:\Users\runneradmin\openquake\Scripts\oq.exe' dbserver start}
oq engine --run D:\a\oq-engine\oq-engine\demos\risk\ClassicalDamage\job_hazard.ini
python -m pip install pytest
pytest -vs --color=yes D:\a\oq-engine\oq-engine\openquake\sep D:\a\oq-engine\oq-engine\openquake\hazardlib\tests\gsim\kotha_2020_test.py D:\a\oq-engine\oq-engine\openquake\calculators
2 changes: 1 addition & 1 deletion ansible/cluster/templates/openquake.zmq.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ port = 1908
# port range used by workers to send back results
# to the master node
receiver_ports = 1921-1930
authkey = changeme

[webapi]
server = "http://{{ server_host }}:8800"
username =
password =
authkey = changeme

[zworkers]
host_cores =
Expand Down
29 changes: 0 additions & 29 deletions debian/patches/openquake.cfg.patch

This file was deleted.

1 change: 0 additions & 1 deletion debian/patches/series
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
openquake.cfg.patch
1 change: 0 additions & 1 deletion debian/python3-oq-engine.install
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
openquake/engine/openquake.cfg /etc/openquake
debian/desktop/oq-engine-webui.desktop /usr/share/applications
debian/desktop/openquake.png /usr/share/pixmaps
debian/systemd/openquake-dbserver.service /lib/systemd/system/
debian/systemd/openquake-webui.service /lib/systemd/system/
demos /usr/share/openquake/engine
utils /usr/share/openquake/engine
2 changes: 0 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ override_dh_gencontrol:
dh_gencontrol -- $(DEPENDS) $(RECOMMENDS)

override_dh_systemd_start:
dh_systemd_start openquake-dbserver.service
dh_systemd_start openquake-webui.service

override_dh_systemd_enable:
dh_systemd_enable openquake-dbserver.service
dh_systemd_enable openquake-webui.service

%:
Expand Down
19 changes: 0 additions & 19 deletions debian/systemd/openquake-dbserver.service

This file was deleted.

5 changes: 2 additions & 3 deletions debian/systemd/openquake-webui.service
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[Unit]
Description=The OpenQuake Engine WebUI
Documentation=https://github.com/gem/oq-engine/
After=network.target openquake-dbserver.service
After=network.target

[Service]
User=openquake
Group=openquake
Environment=
#in WorkingDirectory use the folder of the sources from what are installed the engine
WorkingDirectory=/usr/share/openquake/engine
#in ExecStart use the folder of venv
ExecStart=/opt/openquake/bin/python3 -m openquake.server.manage runserver 127.0.0.1:8800 --noreload
ExecStart=/opt/openquake/bin/python3 -m uvicorn openquake.server.asgi:app --host 127.0.0.1 --port 8800
# Using gunicorn (Nginx or another webserver is needed for static content)
# ExecStart=/opt/openquake/bin/gunicorn --bind 127.0.0.1:8800 --workers 4 --timeout 1200 wsgi:application
Type=exec
Expand Down
8 changes: 0 additions & 8 deletions doc/api-reference/openquake.commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ db command
:undoc-members:
:show-inheritance:

dbserver command
--------------------------------

.. automodule:: openquake.commands.dbserver
:members:
:undoc-members:
:show-inheritance:

engine command
--------------------------------

Expand Down
12 changes: 2 additions & 10 deletions doc/api-reference/openquake.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ Subpackages
Submodules
----------

openquake.server.dbserver module
--------------------------------

.. automodule:: openquake.server.dbserver
:members:
:undoc-members:
:show-inheritance:

openquake.server.manage module
------------------------------

Expand Down Expand Up @@ -68,10 +60,10 @@ openquake.server.views module
:undoc-members:
:show-inheritance:

openquake.server.wsgi module
openquake.server.asgi module
----------------------------

.. automodule:: openquake.server.wsgi
.. automodule:: openquake.server.asgi
:members:
:undoc-members:
:show-inheritance:
Expand Down
1 change: 0 additions & 1 deletion doc/contributing/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ The OpenQuake engine suite is composed of several components:
- the hazard and risk **calculators**, implementing the core logic of the engine
- the **datastore**, which is an HDF5 file working as a short term storage/cache for a calculation; it is possible to run a calculation starting from an existing datastore, to avoid recomputing everything every time; there is a separate datastore for each calculation
- the **database**, which is a SQLite file working as a long term storage for the calculation metadata; the database contains the start/stop times of the computations, the owner of a calculation, the calculation descriptions, the performances, the logs, etc; the bulk scientific data (essentially big arrays) are kept in the datastore
- the **DbServer**, which is a service mediating the interaction between the calculators and the database
- the **WebUI** is a web application that allows to run and monitor computations via a browser; multiple calculations can be run in parallel
- the **oq command-line** tool; it allows to run computations and provides an interface to the underlying database and datastores so that it is possible to list and export the results
- the engine can run on a cluster of machines: in that case a minimal amount of configuration is needed, whereas in single machine installations the engine works out of the box
Expand Down
4 changes: 2 additions & 2 deletions doc/contributing/developing-with-the-engine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ automatic tests executed by GitHub, i.e. the GitHub Actions.
This manual will focus solely on the OpenQuake engine and it assumes
that you already know how to use it, i.e. you have read the User
Manual first. It is also useful to have an idea of the architecture
of the engine and its components, like the DbServer and the
of the engine and its components, like the
WebUI. For that you should read the :ref:`Architecture of the
OpenQuake engine <architecture-of-oq-engine>` section.

Expand All @@ -49,7 +49,7 @@ The first thing to do

The first thing to do if you want to develop with the engine is to remove any non-development installation of the engine
that you may have. While it is perfectly possible to install on the same machine both a development and a production
instance of the engine (it is enough to configure the ports of the DbServer and WebUI) it is easier to work with a
instance of the engine (it is enough to configure the port of the WebUI) it is easier to work with a
single instance. In that way you will have a single code base and no risks of editing the wrong code. A development
installation the engine works as any other development installation in Python: you should clone the engine repository,
create and activate a virtualenv and then perform a *pip install -e* . from the engine main directory, as normal. You can
Expand Down
15 changes: 5 additions & 10 deletions doc/getting-started/installation-instructions/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ It is not necessary to configure `openquake.cfg` for `/opt/openquake/venv`
### Network and security considerations

The worker nodes should be isolated from the external network using
either a dedicated internal network or a firewall. Additionally,
access to the DbServer ports should be limited (again by internal LAN
or firewall) so that external traffic is excluded.
either a dedicated internal network or a firewall. Also the WebUI
is meant to be used internally and should not face the public directly.

The following ports must be open on the **master node**:

* 1908 for DbServer (or any other port allocated for the DbServer in the `openquake.cfg`)
* 1912-1920 for ZeroMQ receivers
* 8800 for the API/WebUI (optional)

Expand Down Expand Up @@ -124,9 +122,7 @@ oq_distribute = zmq
# on multi-node cluster it must be the IP or hostname
# of the master node (on the master node cfg too)
host = < IP address of master>
port = 1908
receiver_ports = 1912-1920
authkey = somethingstronger

[zworkers]
host_cores = < IP address of worker1> -1, < IP address of worker2> -1
Expand All @@ -144,14 +140,13 @@ workers that you want to use.
NB: when using the zmq mechanism you should not touch the parameter
`serialize_jobs` and keep it at its default value of `true`.

### Configuring daemons
### Configuring the WebUI service

The required systemd services are configured from the universal installer into the folder /etc/systemd/system/
The required systemd service is configured by the universal installer into the folder /etc/systemd/system/

#### Master node

- OpenQuake Engine DbServer - `openquake-dbserver.service`
- OpenQuake Engine WebUI - `openquake-webui.service` (optional)
- OpenQuake Engine WebUI - `openquake-webui.service`

### Monitoring zmq

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,11 @@ page.
Sync the source code with remote
--------------------------------

You can pull all the latest changes to the source code running
You can pull all the latest changes to the source code by running

.. code:: bash

cd oq-engine
oq dbserver stop
git pull

Uninstall the OpenQuake Engine
Expand Down
18 changes: 2 additions & 16 deletions doc/getting-started/installation-instructions/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sudo mkdir /var/log/oq-engine
sudo chown -R openquake /var/log/oq-engine
```

#### Configuring the DbServer host
#### Configuring the database host

If the database file is on the local machine, there is nothing to do
since the universal installer already writes in the `openquake.cfg`
Expand All @@ -72,7 +72,7 @@ If the database is on a different machine, you have to edit the file and
specify the correct host name.

NB: setting `host=127.0.0.1` is a mistake, since it will result on the
database being accessed directly bypassing the DbServer, which is a problem,
database being accessed directly, which is a problem,
since regular users will not have write permission to it. `host=127.0.0.1`
instead is correct for single-user installations and correctly set by
the universal installer.
Expand Down Expand Up @@ -183,20 +183,6 @@ where `N` is the number of workers. We suggest `N = 4`.

Systemd has Environment directive which sets environment variables for executed processes. It takes a space-separated list of variable assignments. This option may be specified more than once in which case all listed variables will be set. If the same variable is set twice, the later setting will override the earlier setting. If the empty string is assigned to this option, the list of environment variables is reset, all prior assignments have no effect.

With example below you can configure dbserver daemon with the DJANGO_SETTINGS_MODULE variable.

Just edit `/etc/systemd/system/openquake-dbserver.service` for openquake-dbserver.service:

```
[Service]
# Env Vars
Environment=DJANGO_SETTINGS_MODULE=openquake.server.settings

```

Then run `sudo systemctl daemon-reload` and `sudo systemct restart openquake-dbserver.service` to apply new environments to dbserver daemon.


### Limit systemd services with control group (slice)

If you need to set a limit on the resources available for the OpenQuake service, Systemd offers a simple solution to create resource limits for a service,
Expand Down
7 changes: 3 additions & 4 deletions doc/getting-started/installation-instructions/universal.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ We recommend to keep the file openquake.cfg in the $HOME folder to avoid losing

If you are on a Linux machine _and_ you have root permissions, the
recommended installation method is `server`. In this case, the engine
will work with multiple users and two system V services will be
automatically installed and started: `openquake-dbserver` and
`openquake-webui`.
will work with multiple users and a system V service will be
automatically installed and started: `openquake-webui`.

```
$ curl -L -O https://github.com/gem/oq-engine/raw/master/install.py
Expand All @@ -189,7 +188,7 @@ The installation script will automatically create a user called

*NB*: if you already have an engine installation made with debian or rpm
packages, before installing the new version you must uninstall the old
version, make sure that the dbserver and webui services are actually
version, make sure that the webui is actually
stopped and then also remove the directory `/opt/openquake` and the
configuration file `/etc/openquake/openquake.cfg`. If you want to
preserve some configuration (like the [zworkers] section which is needed
Expand Down
4 changes: 2 additions & 2 deletions doc/user-guide/advanced/useful-oq-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ You can see the full list of commands by running *oq –help*::

$ oq --help
usage: oq [-h] [-v]
{shell,upgrade_nrml,reduce_smlt,show_attrs,prepare_site_model,nrml_from,shakemap2gmfs,importcalc,run,show,purge,renumber_sm,workers,postzip,plot_assets,db,dbserver,tidy,extract,sample,to_hdf5,ltcsv,reaggregate,restore,mosaic,check_input,dump,info,zip,abort,nrml_to,engine,reset,checksum,export,webui,compare,plot,reduce_sm}
{shell,upgrade_nrml,reduce_smlt,show_attrs,prepare_site_model,nrml_from,shakemap2gmfs,importcalc,run,show,purge,renumber_sm,workers,postzip,plot_assets,db,tidy,extract,sample,to_hdf5,ltcsv,reaggregate,restore,mosaic,check_input,dump,info,zip,abort,nrml_to,engine,reset,checksum,export,webui,compare,plot,reduce_sm}
...

positional arguments:
{shell,upgrade_nrml,reduce_smlt,show_attrs,prepare_site_model,nrml_from,shakemap2gmfs,importcalc,run,show,purge,renumber_sm,workers,postzip,plot_assets,db,dbserver,tidy,extract,sample,to_hdf5,ltcsv,reaggregate,restore,mosaic,check_input,dump,info,zip,abort,nrml_to,engine,reset,checksum,export,webui,compare,plot,reduce_sm}
{shell,upgrade_nrml,reduce_smlt,show_attrs,prepare_site_model,nrml_from,shakemap2gmfs,importcalc,run,show,purge,renumber_sm,workers,postzip,plot_assets,db,tidy,extract,sample,to_hdf5,ltcsv,reaggregate,restore,mosaic,check_input,dump,info,zip,abort,nrml_to,engine,reset,checksum,export,webui,compare,plot,reduce_sm}
available subcommands; use oq <subcmd> --help

options:
Expand Down
11 changes: 0 additions & 11 deletions doc/user-guide/extras/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ command::

to retrieve the path of its virtual environment.

Another parameter accepted by the ``install.py`` script is
``--dbport``, that specifies the port number used by the engine
dbserver. This is only relevant for server installations. By default,
the port is set to 1907. The port can be customized through the
attribute ``port`` of section ``[dbserver]`` in the configuration file
``openquake.cfg``, placed inside the virtual environment directory,
e.g.::

[dbserver]
port = 1908

########################################################################
Can two installations of the engine share the same ``oqdata`` directory?
########################################################################
Expand Down
2 changes: 1 addition & 1 deletion docker/openquake.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ port = 1908
# port range used by workers to send back results
# to the master node
receiver_ports = 1921-1930
authkey = changeme

[webapi]
server = http://127.0.0.1:8800
username =
password =
authkey = changeme

[zworkers]
host_cores =
Expand Down
21 changes: 7 additions & 14 deletions openquake/baselib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,14 @@ def read(*paths, **validators):
if 'OQ_DISTRIBUTE' not in os.environ:
os.environ['OQ_DISTRIBUTE'] = config.distribution.oq_distribute

# wether the engine was installed as multi_user (linux root) or not
if sys.platform in 'win32 darwin':
config.multi_user = False
else: # linux
import pwd
try:
install_user = pwd.getpwuid(os.stat(__file__).st_uid).pw_name
except KeyError: # on the IUSS cluster
install_user = None
config.multi_user = install_user in ('root', 'openquake')


def via_server():

def multi_user():
return config.dbserver.host != '127.0.0.1'


def use_server():
""":returns: True for regular users in a server installation"""
return config.multi_user and getpass.getuser() != 'openquake'
return multi_user() and getpass.getuser() != 'openquake'


# the version is managed by the universal installer
Expand Down
Loading