Add more maintenance tasks as services

This commit is contained in:
Antonio J. Delgado 2023-12-11 10:38:21 +02:00
parent 3843cc7c19
commit 4904ffbe65

View file

@ -505,8 +505,103 @@ class mastodon (
active => true,
enable => true,
}
# tootctl maintenance fix-duplicates
# tootctl media remove --days 180
# tootctl media remove-orphans
# tootctl preview_cards remove --days 180
$_timer_remove_media = @("EOT")
[Unit]
Description=Mastodon - Remove old media
[Timer]
OnBootSec=24min
OnUnitActiveSec=1d
Unit=mastodon_remove_media.service
[Install]
WantedBy=timers.target
| EOT
$_service_remove_media = @("EOT")
[Service]
Type=simple
User=${mastodon_user}
WorkingDirectory=${mastodon_home}/live
Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
ExecStart=/opt/mastodon/live/bin/tootctl media remove --days 180
[Unit]
OnFailure=status_email_antoniodelgado@%n.service
| EOT
systemd::timer { 'mastodon_remove_media.timer':
ensure => present,
timer_content => $_timer_remove_media,
service_unit => 'mastodon_remove_media.service',
service_content => $_service_remove_media,
active => true,
enable => true,
}
$_timer_remove_orphans = @("EOT")
[Unit]
Description=Mastodon - Remove orphans
[Timer]
OnBootSec=24min
OnUnitActiveSec=1d
Unit=mastodon_remove_orphans.service
[Install]
WantedBy=timers.target
| EOT
$_service_remove_orphans = @("EOT")
[Service]
Type=simple
User=${mastodon_user}
WorkingDirectory=${mastodon_home}/live
Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
ExecStart=/opt/mastodon/live/bin/tootctl remove-orphans
[Unit]
OnFailure=status_email_antoniodelgado@%n.service
| EOT
systemd::timer { 'mastodon_remove_orphans.timer':
ensure => present,
timer_content => $_timer_remove_orphans,
service_unit => 'mastodon_remove_orphans.service',
service_content => $_service_remove_orphans,
active => true,
enable => true,
}
$_timer_remove_cards = @("EOT")
[Unit]
Description=Mastodon - Remove old media
[Timer]
OnBootSec=24min
OnUnitActiveSec=1d
Unit=mastodon_remove_cards.service
[Install]
WantedBy=timers.target
| EOT
$_service_remove_cards = @("EOT")
[Service]
Type=simple
User=${mastodon_user}
WorkingDirectory=${mastodon_home}/live
Environment='RAILS_ENV=production' 'PATH=${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
ExecStart=/opt/mastodon/live/bin/tootctl preview_cards remove --days 180
[Unit]
OnFailure=status_email_antoniodelgado@%n.service
| EOT
systemd::timer { 'mastodon_remove_cards.timer':
ensure => present,
timer_content => $_timer_remove_cards,
service_unit => 'mastodon_remove_cards.service',
service_content => $_service_remove_cards,
active => true,
enable => true,
}
}