aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/commons/stats.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-02-15 09:48:28 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-02-15 09:48:28 +0100
commit7c059af8158354397885b720395b40976d9e351d (patch)
treeaf361aba02f4ea94c4125a7b9fce90979a280954 /nixops/modules/websites/commons/stats.nix
parent0eaac6ba283159841da70fdfd74cb0ef7c6203ab (diff)
downloadNix-7c059af8158354397885b720395b40976d9e351d.tar.gz
Nix-7c059af8158354397885b720395b40976d9e351d.tar.zst
Nix-7c059af8158354397885b720395b40976d9e351d.zip
Do stats computation sequentially
We do it now sequentially rather than relying on the previous job taking less than one minute to finish (which is unlikely as the size of the logs grow) Goaccess doesn’t like to be started twice concurrently, so sequential is needed Fixes https://git.immae.eu/mantisbt/view.php?id=110
Diffstat (limited to 'nixops/modules/websites/commons/stats.nix')
-rw-r--r--nixops/modules/websites/commons/stats.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixops/modules/websites/commons/stats.nix b/nixops/modules/websites/commons/stats.nix
index b5bf0e0..e2c1e62 100644
--- a/nixops/modules/websites/commons/stats.nix
+++ b/nixops/modules/websites/commons/stats.nix
@@ -55,8 +55,15 @@ in {
55 goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${conf} 55 goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${conf}
56 ''; 56 '';
57 in "${d}/bin/stats-${domain}"; 57 in "${d}/bin/stats-${domain}";
58 allStats = sites: pkgs.writeScript "stats" ''
59 #!${pkgs.stdenv.shell}
60
61 ${builtins.concatStringsSep "\n" (map (v: stats v.name v.conf) sites)}
62 '';
58 in 63 in
59 pkgs.lib.lists.imap0 (i: v: "${toString (i+5)} 0 * * * root ${stats v.name v.conf}") cfg.sites; 64 [
65 "5 0 * * * root ${allStats cfg.sites}"
66 ];
60 }; 67 };
61 68
62 system.activationScripts.goaccess = '' 69 system.activationScripts.goaccess = ''