Skip to content

Commit 93ada95

Browse files
takackiriwalawren
andauthored
fix: wait for arr service to be ready for download clients (#128)
* fix: wait for arr service to be ready before configuring download clients The downloadclients oneshot service only depended on the config service, not the arr service itself. Since arr services use Type=simple, systemd considers them active as soon as the process starts — before they are actually listening on their port. This caused the downloadclients service to fail at boot with connection refused errors. Add the arr service to After/Requires and add an ExecStartPre readiness check using curl --retry-connrefused to wait until the API is accepting connections before proceeding. * fix formatting --------- Co-authored-by: Kiri Carlson <kiri@walawren.com>
1 parent 0e4844b commit 93ada95

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

modules/downloadarr/service.nix

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,24 @@ let
6666
{
6767
"${serviceName}-downloadclients" = {
6868
description = "Configure ${serviceName} download clients via API";
69-
after = [ "${serviceName}-config.service" ] ++ clientDependencies;
70-
requires = [ "${serviceName}-config.service" ] ++ clientDependencies;
69+
after = [
70+
"${serviceName}.service"
71+
"${serviceName}-config.service"
72+
]
73+
++ clientDependencies;
74+
requires = [
75+
"${serviceName}.service"
76+
"${serviceName}-config.service"
77+
]
78+
++ clientDependencies;
7179
wantedBy = [ "multi-user.target" ];
7280

7381
serviceConfig = {
7482
Type = "oneshot";
7583
RemainAfterExit = true;
84+
ExecStartPre =
85+
"${pkgs.curl}/bin/curl --retry 30 --retry-delay 2 --retry-connrefused -so /dev/null"
86+
+ " http://127.0.0.1:${builtins.toString serviceConfig.hostConfig.port}${serviceConfig.hostConfig.urlBase}/api/${serviceConfig.apiVersion}/system/status";
7687
};
7788

7889
script = ''

0 commit comments

Comments
 (0)