Revert "Add logrotate script"

The latest version of misskey does not store logs in the database, so no
need to rotate them out. Win!
This commit is contained in:
jaina heartles 2024-02-27 19:39:19 -08:00
parent 49fe919795
commit 3296b3a7cf

View file

@ -1,4 +1,4 @@
{ pkgs, config, ... }: { pkgs, ... }:
let let
nodejs = pkgs.unstable.nodejs_20; nodejs = pkgs.unstable.nodejs_20;
@ -14,7 +14,6 @@ in {
name = "misskey"; name = "misskey";
ensureDBOwnership = true; ensureDBOwnership = true;
} }
{ name = "logrotate"; }
{ name = "postgres"; } { name = "postgres"; }
]; ];
ensureDatabases = [ "misskey" ]; 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.groups.misskey = { members = [ "jaina" ]; };
users.users.misskey = { users.users.misskey = {
isSystemUser = true; isSystemUser = true;