Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed multi_user flag
  • Loading branch information
micheles committed Sep 13, 2021
1 parent 3441076 commit 007560c
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 31 deletions.
4 changes: 0 additions & 4 deletions ansible/cluster/templates/openquake.zmq.cfg.j2
Expand Up @@ -14,8 +14,6 @@
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.

[distribution]
# set multi_node = true if are on a cluster
multi_node = true
oq_distribute = zmq
# make sure workers are terminated when tasks are revoked
terminate_workers_on_revoke = true
Expand All @@ -34,8 +32,6 @@ hard_mem_limit = 98
# RabbitMQ server address

[dbserver]
# enable multi_user if you have a multiple user installation
multi_user = true
file = {{ workdir_services }}/oqdata/db.sqlite3
# daemon bind address; must be a valid IP address
# example: 0.0.0.0
Expand Down
6 changes: 1 addition & 5 deletions debian/patches/openquake.cfg.patch
Expand Up @@ -2,15 +2,11 @@ Index: oq-engine/openquake/engine/openquake.cfg
===================================================================
--- a/openquake/engine/openquake.cfg
+++ b/openquake/engine/openquake.cfg
@@ -44,9 +44,9 @@
@@ -44,7 +44,7 @@
celery_queue = celery

[dbserver]
-# enable multi_user if you have a multiple user installation
-multi_user = false
-file = ~/oqdata/db.sqlite3
+# run in multi_user mode
+multi_user = true
+file = /var/lib/openquake/db.sqlite3
# daemon bind address; must be a valid IP address
# example: 0.0.0.0
Expand Down
1 change: 0 additions & 1 deletion doc/installing/cluster-celery.md
Expand Up @@ -52,7 +52,6 @@ vhost = openquake
celery_queue = celery

[dbserver]
multi_user = true
file = /var/lib/openquake/db.sqlite3
# daemon bind address; must be a valid IP address
listen = 0.0.0.0
Expand Down
1 change: 0 additions & 1 deletion doc/installing/cluster.md
Expand Up @@ -111,7 +111,6 @@ The following file (on all nodes) should be modified to enable
oq_distribute = zmq
[dbserver]
multi_user = true
file = /var/lib/openquake/oqdata/db.sqlite3
# daemon bind address; must be a valid IP address
listen = < IP address of master>
Expand Down
3 changes: 0 additions & 3 deletions docker/openquake.cfg
Expand Up @@ -17,7 +17,6 @@
strict = false

[distribution]
multi_node = true
oq_distribute = zmq
terminate_workers_on_revoke = true
serialize_jobs = 1
Expand All @@ -30,8 +29,6 @@ soft_mem_limit = 90
hard_mem_limit = 98

[dbserver]
# enable multi_user if you have a multiple user installation
multi_user = false
file = /home/openquake/oqdata/db.sqlite3
# daemon bind address; must be a valid IP address
# example: 0.0.0.0
Expand Down
2 changes: 0 additions & 2 deletions install.py
Expand Up @@ -72,7 +72,6 @@ class server:
DBPORT = 1907
CONFIG = '''[dbserver]
port = %d
multi_user = true
file = %s
shared_dir = /var/lib
''' % (DBPORT, DBPATH)
Expand All @@ -91,7 +90,6 @@ class devel_server:
DBPORT = 1907
CONFIG = '''[dbserver]
port = %d
multi_user = true
file = %s
shared_dir = /var/lib
''' % (DBPORT, DBPATH)
Expand Down
12 changes: 8 additions & 4 deletions openquake/baselib/__init__.py
Expand Up @@ -18,6 +18,7 @@

import os
import sys
import getpass
import numpy
import scipy
import pandas
Expand Down Expand Up @@ -59,8 +60,8 @@ def __getattr__(self, key):
base = os.path.join(d(d(__file__)), 'engine', 'openquake.cfg')
# 'virtualenv' still uses 'real_prefix' also on Python 3
# removal of this breaks Travis
if (hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix')
and sys.base_prefix != sys.prefix)):
if hasattr(sys, 'real_prefix') or (
hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
config.paths = [base, os.path.join(sys.prefix, 'openquake.cfg')]
else: # installation from sources or packages, search in $HOME or /etc
config.paths = [base, '/etc/openquake/openquake.cfg', '~/openquake.cfg']
Expand Down Expand Up @@ -125,11 +126,14 @@ def positiveint(flag):


config.read(limit=int, soft_mem_limit=int, hard_mem_limit=int, port=int,
multi_user=positiveint, serialize_jobs=positiveint,
strict=positiveint, code=exec)
serialize_jobs=positiveint, strict=positiveint, code=exec)

if config.directory.custom_tmp:
os.environ['TMPDIR'] = config.directory.custom_tmp

if 'OQ_DISTRIBUTE' not in os.environ:
os.environ['OQ_DISTRIBUTE'] = config.distribution.oq_distribute


# wether the engine is installed in /home/<user> or not
config['multi_user'] = not __file__.startswith('/home/' + getpass.getuser())
2 changes: 1 addition & 1 deletion openquake/commands/db.py
Expand Up @@ -53,7 +53,7 @@ def main(cmd, args=()):
sys.exit('Wrong number of arguments, expected %s, got %s' % (
commands[cmd], args))
elif (cmd not in commands and not cmd.upper().startswith('SELECT') and
config.dbserver.multi_user and getpass.getuser() != 'openquake'):
config.multi_user and getpass.getuser() != 'openquake'):
sys.exit('You have no permission to run %s' % cmd)
dbserver.ensure_on()
res = logs.dbcmd(cmd, *convert(args))
Expand Down
2 changes: 1 addition & 1 deletion openquake/commands/dbserver.py
Expand Up @@ -32,7 +32,7 @@ def main(cmd,
"""
start/stop/restart the database server, or return its status
"""
if config.dbserver.multi_user and getpass.getuser() != 'openquake':
if config.multi_user and getpass.getuser() != 'openquake':
sys.exit('oq dbserver only works in single user mode')

status = dbs.get_status()
Expand Down
5 changes: 2 additions & 3 deletions openquake/commands/engine.py
Expand Up @@ -106,9 +106,8 @@ def main(
if config_file:
config.read(os.path.abspath(os.path.expanduser(config_file)),
limit=int, soft_mem_limit=int, hard_mem_limit=int,
port=int, multi_user=valid.boolean,
serialize_jobs=valid.boolean, strict=valid.boolean,
code=exec)
port=int, serialize_jobs=valid.boolean,
strict=valid.boolean, code=exec)

if no_distribute:
os.environ['OQ_DISTRIBUTE'] = 'no'
Expand Down
2 changes: 1 addition & 1 deletion openquake/commands/workers.py
Expand Up @@ -25,7 +25,7 @@ def main(cmd):
"""
start/stop the workers, or return their status
"""
if (cmd != 'status' and config.dbserver.multi_user and
if (cmd != 'status' and config.multi_user and
getpass.getuser() not in 'openquake'):
sys.exit('oq workers only works in single user mode')
if p.OQDIST in ('dask', 'celery', 'zmq'):
Expand Down
2 changes: 0 additions & 2 deletions openquake/engine/openquake.cfg
Expand Up @@ -40,8 +40,6 @@ vhost = openquake
celery_queue = celery

[dbserver]
# enable multi_user if you have a multiple user installation
multi_user = false
file = ~/oqdata/db.sqlite3
# daemon bind address; must be a valid IP address
# example: 0.0.0.0
Expand Down
6 changes: 3 additions & 3 deletions openquake/server/dbserver.py
Expand Up @@ -145,7 +145,7 @@ def check_foreign():
"""
Check if we the DbServer is the right one
"""
if not config.dbserver.multi_user:
if not config.multi_user:
remote_server_path = logs.dbcmd('get_path')
if different_paths(server_path, remote_server_path):
return('You are trying to contact a DbServer from another'
Expand All @@ -159,7 +159,7 @@ def ensure_on():
Start the DbServer if it is off
"""
if get_status() == 'not-running':
if config.dbserver.multi_user:
if config.multi_user:
sys.exit('Please start the DbServer: '
'see the documentation for details')
# otherwise start the DbServer automatically; NB: I tried to use
Expand Down Expand Up @@ -209,7 +209,7 @@ def run_server(dbhostport=None, loglevel='WARN', foreground=False):
actions.reset_is_running(db)

# start the dbserver
if hasattr(os, 'fork') and not (config.dbserver.multi_user or foreground):
if hasattr(os, 'fork') and not (config.multi_user or foreground):
# needed for https://github.com/gem/oq-engine/issues/3211
# but only if multi_user = False, otherwise init/supervisor
# will loose control of the process
Expand Down

0 comments on commit 007560c

Please sign in to comment.