From 6cc9ca96747f555fc7092c62a12c0e41b85b5436 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Sat, 22 Jun 2024 14:27:44 +0300 Subject: [PATCH] use /run/ahriman for sockett --- docs/faq.rst | 4 ++-- src/ahriman/application/lock.py | 4 ++-- tests/ahriman/application/test_lock.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index c17ce015..dcb9b268 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -475,7 +475,7 @@ The following environment variables are supported: * ``AHRIMAN_REPOSITORY`` - repository name, default is ``aur-clone``. * ``AHRIMAN_REPOSITORY_SERVER`` - optional override for the repository URL. Useful if you would like to download packages from remote instead of local filesystem. * ``AHRIMAN_REPOSITORY_ROOT`` - repository root. Because of filesystem rights it is required to override default repository root. By default, it uses ``ahriman`` directory inside ahriman's home, which can be passed as mount volume. -* ``AHRIMAN_UNIX_SOCKET`` - full path to unix socket which is used by web server, default is empty. Note that more likely you would like to put it inside ``AHRIMAN_REPOSITORY_ROOT`` directory (e.g. ``/var/lib/ahriman/ahriman/ahriman-web.sock``) or to ``/tmp``. +* ``AHRIMAN_UNIX_SOCKET`` - full path to unix socket which is used by web server, default is empty. Note that more likely you would like to put it inside ``AHRIMAN_REPOSITORY_ROOT`` directory (e.g. ``/var/lib/ahriman/ahriman/ahriman-web.sock``) or to ``/run/ahriman``. * ``AHRIMAN_USER`` - ahriman user, usually must not be overwritten, default is ``ahriman``. * ``AHRIMAN_VALIDATE_CONFIGURATION`` - if set (default) validate service configuration. @@ -1318,7 +1318,7 @@ How to enable basic authorization .. code-block:: ini [web] - unix_socket = /var/lib/ahriman/ahriman-web.sock + unix_socket = /run/ahriman/ahriman-web.sock This socket path must be available for web service instance and must be available for all application instances (e.g. in case if you are using docker container - see above - you need to make sure that the socket is passed to the root filesystem). diff --git a/src/ahriman/application/lock.py b/src/ahriman/application/lock.py index cd6fc214..7cae1b5f 100644 --- a/src/ahriman/application/lock.py +++ b/src/ahriman/application/lock.py @@ -125,7 +125,7 @@ class Lock(LazyLogging): return waiter = Waiter(self.wait_timeout) - waiter.wait(self.perform_lock, self._pid_file.fileno()) + waiter.wait(lambda fd: not self.perform_lock(fd), self._pid_file.fileno()) def _write(self) -> None: """ @@ -139,7 +139,7 @@ class Lock(LazyLogging): if not self.perform_lock(self._pid_file.fileno()): raise DuplicateRunError - self._pid_file.seek(0) # reset bytes + self._pid_file.seek(0) # reset position and remove file content if any self._pid_file.truncate() self._pid_file.write(str(os.getpid())) # write current pid diff --git a/tests/ahriman/application/test_lock.py b/tests/ahriman/application/test_lock.py index dafca3ad..428d8ffb 100644 --- a/tests/ahriman/application/test_lock.py +++ b/tests/ahriman/application/test_lock.py @@ -81,7 +81,7 @@ def test_watch(lock: Lock, mocker: MockerFixture) -> None: wait_mock = mocker.patch("ahriman.models.waiter.Waiter.wait") lock._watch() - wait_mock.assert_called_once_with(lock.perform_lock, 1) + wait_mock.assert_called_once_with(pytest.helpers.anyvar(int), 1) def test_watch_skip(lock: Lock, mocker: MockerFixture) -> None: