@cryptotaxi247 / infra / commits / 0069e433

Add systemd timer

Eelco Dolstra committed Sep 27, 2022 at 15:56 UTC 0069e4339a9b540a855a8691cf291821ac272259
2 files changed +37 -1
cron.sh
+9 -1
@@ -11,7 +11,15 @@ to_date_incl=$(date +%F --date="@$(($prev_week * 86400 * 7 + 5 * 86400))")
11
12 echo "Ingesting [$from_date_incl, $to_date_incl)."
13
14 -#exit 0
14 +marker="$HOME/weeks-done/$prev_week"
15 +
16 +if [[ -e $marker ]]; then
17 + echo "Already done!"
18 + exit 0
19 +fi
20 +
21 +mkdir -p "$(dirname "$marker")"
22 +touch $marker
23
24 ./ingest-raw-logs.sh "$from_date_incl" "$to_date_incl"
25
flake.nix new
+28
@@ -0,0 +1,28 @@
1 +{
2 + outputs = { self, nixpkgs }: {
3 + nixosModules.nix-metrics = { config, pkgs, ... }: {
4 +
5 + users.users.nix-metrics =
6 + { isNormalUser = true;
7 + description = "Nix Metrics Collection";
8 + };
9 +
10 + systemd.services.process-raw-nix-logs = {
11 + description = "Process Raw nixos.org Logs";
12 + serviceConfig.Type = "oneshot";
13 + serviceConfig.User = "nix-metrics";
14 + path =
15 + [ pkgs.awscli
16 + pkgs.jq
17 + ];
18 + script =
19 + ''
20 + cd ${./.}
21 + ./cron.sh
22 + '';
23 + startAt = "Tue 07:30";
24 + };
25 +
26 + };
27 + };
28 +}