Delete old Mastodon media cache every day

This is done using a systemd timer

Closes #533
This commit is contained in:
Greg Karekinian 2025-05-16 18:10:11 +02:00
parent 160134bd86
commit b01315f998

View File

@ -265,6 +265,41 @@ service "mastodon-streaming" do
action [:enable, :start]
end
# Delete old media cache
systemd_unit 'mastodon-delete-old-media-cache.service' do
content({
Unit: {
Description: 'Delete old Mastodon media cache'
},
Service: {
Type: "oneshot",
WorkingDirectory: "#{mastodon_path}",
Environment: "\"RAILS_ENV=#{rails_env}\"",
ExecStart: "#{bundle_path} exec bin/tootctl media remove --days 30",
SyslogIdentifier: "mastodon-delete-old-media-cache"
}
})
action [:create]
end
systemd_unit 'mastodon-delete-old-media-cache.timer' do
content({
Unit: {
Description: 'Delete old Mastodon media cache'
},
Timer: {
OnCalendar: '*-*-* 00:00:00',
Persistent: 'true'
},
Install: {
WantedBy: 'timers.target'
}
})
triggers_reload true
action [:create, :enable, :start]
end
firewall_rule "mastodon_app" do
port node['kosmos-mastodon']['app_port']
source "10.1.1.0/24"