Skip to content

Commit c683d96

Browse files
authored
nixos/matomo: fix service failure when not fully set up (#373894)
2 parents 0243bf6 + fc6d9cc commit c683d96

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

nixos/modules/services/web-apps/matomo.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ in {
183183
chmod -R u+rwX,g+rwX,o-rwx "${dataDir}"
184184
185185
# check whether user setup has already been done
186-
if test -f "${dataDir}/config/config.ini.php"; then
186+
if test -f "${dataDir}/config/config.ini.php" &&
187+
# since matomo-5.2.0, the config.ini.php is already created at first
188+
# installer page access https://github.com/matomo-org/matomo/issues/22932
189+
grep -q -F "[database]" "${dataDir}/config/config.ini.php"; then
187190
# then execute possibly pending database upgrade
188191
matomo-console core:update --yes
189192
fi

nixos/tests/matomo.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,25 @@ let
3737
machine.wait_for_unit("phpfpm-matomo.service")
3838
machine.wait_for_unit("nginx.service")
3939
40+
with subtest("matomo.js reachable via HTTP"):
41+
machine.succeed("curl -sSfk http://machine/matomo.js")
42+
43+
with subtest("js/piwik.js reachable via HTTP"):
44+
machine.succeed("curl -sSfk http://machine/js/piwik.js")
45+
46+
with subtest("matomo.php (API) reachable via HTTP"):
47+
machine.succeed("curl -sSfk http://machine/matomo.php")
48+
4049
# without the grep the command does not produce valid utf-8 for some reason
4150
with subtest("welcome screen loads"):
4251
machine.succeed(
4352
"curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
4453
)
54+
55+
with subtest("killing the phpfpm process should trigger an automatic restart"):
56+
machine.succeed("systemctl kill -s KILL phpfpm-matomo")
57+
machine.sleep(1)
58+
machine.wait_for_unit("phpfpm-matomo.service")
4559
'';
4660
};
4761
in

0 commit comments

Comments
 (0)