From: Ismaël Bouya Date: Fri, 15 Feb 2019 08:48:28 +0000 (+0100) Subject: Do stats computation sequentially X-Git-Tag: nur_publish~240 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=7c059af8158354397885b720395b40976d9e351d 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 --- 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 { goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${conf} ''; in "${d}/bin/stats-${domain}"; + allStats = sites: pkgs.writeScript "stats" '' + #!${pkgs.stdenv.shell} + + ${builtins.concatStringsSep "\n" (map (v: stats v.name v.conf) sites)} + ''; in - pkgs.lib.lists.imap0 (i: v: "${toString (i+5)} 0 * * * root ${stats v.name v.conf}") cfg.sites; + [ + "5 0 * * * root ${allStats cfg.sites}" + ]; }; system.activationScripts.goaccess = ''