From 5b6881f4a0797cf7cc6c3350c4bc784a851e0124 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Mon, 2 Jan 2023 12:19:27 +0100 Subject: [PATCH] nixos/paperless-ngx: fix startup order The nixOS test failed sporadically with a timeout. This is due to a race condition in the startup of the scheduler vs the task-queue. The scheduler runs the migration scripts in "pre-start" and celery isn't available, yet. The celery worker (paperless-task-queue) was already started by systemd but was unable to connect (as the migration scripts from "pre-start" still ran). This fix adds the necessary "after" condition in the systemd worker unit and adds a test to "paperless" Signed-off-by: Florian Brandes --- nixos/modules/services/misc/paperless.nix | 1 + nixos/tests/paperless.nix | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 33a8394dff2d..54c53a011343 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -258,6 +258,7 @@ in PrivateNetwork = false; }; environment = env; + after = [ "paperless-scheduler.service" ]; }; # Reading the user-provided password file requires root access diff --git a/nixos/tests/paperless.nix b/nixos/tests/paperless.nix index b97834835c2c..7f36de4c29b7 100644 --- a/nixos/tests/paperless.nix +++ b/nixos/tests/paperless.nix @@ -26,6 +26,10 @@ import ./make-test-python.nix ({ lib, ... }: { # Wait until server accepts connections machine.wait_until_succeeds("curl -fs localhost:28981") + # Required for consuming documents via the web interface + with subtest("Task-queue gets ready"): + machine.wait_for_unit("paperless-task-queue.service") + with subtest("Add a document via the web interface"): machine.succeed( "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black "