From 3296b3a7cf797597d735c22954c8df431da080df Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Tue, 27 Feb 2024 19:39:19 -0800 Subject: [PATCH] Revert "Add logrotate script" The latest version of misskey does not store logs in the database, so no need to rotate them out. Win! --- misskey-service.nix | 59 +-------------------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/misskey-service.nix b/misskey-service.nix index 6c82888..d152dfb 100644 --- a/misskey-service.nix +++ b/misskey-service.nix @@ -1,4 +1,4 @@ -{ pkgs, config, ... }: +{ pkgs, ... }: let nodejs = pkgs.unstable.nodejs_20; @@ -14,7 +14,6 @@ in { name = "misskey"; ensureDBOwnership = true; } - { name = "logrotate"; } { name = "postgres"; } ]; ensureDatabases = [ "misskey" ]; @@ -160,62 +159,6 @@ in { }; }; - services.cron = { - enable = true; - systemCronJobs = let - logrotateScript = pkgs.writeShellApplication { - name = "logrotate.sh"; - runtimeInputs = with pkgs; [ - s3cmd - coreutils - bc - config.services.postgresql.package - ]; - text = '' - now="$(date +%s)" - stamp="$(echo "$now - 2592000" | bc)" - - tmp="$(mktemp -d)" - date="$(date --date="@$stamp" -I)" - file="log-$date.csv.gz" - - - echo "Using temporary dir $tmp" - echo "Collecting logs prior to $date..." - psql misskey -P format=unaligned -F , \ - -c "select * from public.log where \"createdAt\" < to_timestamp($stamp);" \ - | gzip > "$tmp/$file" - - echo "Uploading..." - if s3cmd --config /etc/nixos-secrets/logrotate-s3cfg put "$tmp/$file" s3://log.misskey.egirls.gay/ - then - echo "$file successfully uploaded" - echo "Deleting log records..." - - psql misskey -c "delete from public.log where \"createdAt\" < to_timestamp($stamp)" - rm -rf "$tmp" - - echo "Done." - exit - fi - - echo "Error uploading file. Records have not been touched" 1>&2 - rm -rf "$tmp" - ''; - }; - in [ - # Manage logs - # min hour monthday month weekday user command - "30 7 * * * logrotate ${logrotateScript}" - ]; - }; - - users.users.logrotate = { - isSystemUser = true; - group = "logrotate"; - }; - users.groups.logrotate = { }; - users.groups.misskey = { members = [ "jaina" ]; }; users.users.misskey = { isSystemUser = true;