Mercurial > libervia-backend
diff libervia/backend/core/constants.py @ 4202:b26339343076
core: use a user specific directory for PID file:
default location of pid file is now specific to logged user, this allow to run several
instances of Libervia by different users on the same machine without PID conflicts.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jan 2024 17:48:02 +0100 |
parents | 50c919dfe61b |
children | 5a0bddfa34ac |
line wrap: on
line diff
--- a/libervia/backend/core/constants.py Thu Dec 14 09:19:32 2023 +0100 +++ b/libervia/backend/core/constants.py Sun Jan 14 17:48:02 2024 +0100 @@ -21,12 +21,19 @@ from os.path import expanduser, realpath except ImportError: BaseDirectory = None -from os.path import dirname +from os.path import dirname, join import tempfile from typing import Final from libervia import backend +try: + from getpass import getuser +except ImportError: + logged_user = "unkonwn" +else: + logged_user = getuser() + class Const(object): @@ -458,7 +465,6 @@ return cls.BOOL_TRUE if value else cls.BOOL_FALSE - ## Configuration ## if ( BaseDirectory @@ -489,7 +495,7 @@ ).getAbsolutePath(), Const.APP_NAME_FILE, ), - "pid_dir": tempfile.gettempdir(), + "pid_dir": join(tempfile.gettempdir(), Const.APP_NAME_FILE, logged_user), "log_dir": "%(local_dir)s", } Const.CONFIG_FILES = [ @@ -532,7 +538,7 @@ "media_dir": "/usr/share/" + Const.APP_NAME_FILE + "/media", "local_dir": BaseDirectory.save_data_path(Const.APP_NAME_FILE), "downloads_dir": "~/Downloads/" + Const.APP_NAME_FILE, - "pid_dir": tempfile.gettempdir(), + "pid_dir": join(tempfile.gettempdir(), Const.APP_NAME_FILE, logged_user), "log_dir": "%(local_dir)s", }