mirror of https://github.com/zulip/zulip.git
puppet: Factor out cron job creation.
This commit is contained in:
parent
c607594d11
commit
6e981c18d5
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
* * * * * zulip /usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time --site=https://$(/home/zulip/deployments/current/scripts/get-django-setting NAGIOS_BOT_HOST) >/dev/null
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
* * * * * zulip /usr/lib/nagios/plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness >/dev/null
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
0 8 * * * zulip /home/zulip/deployments/current/tools/fetch-contributor-data
|
|
@ -62,11 +62,9 @@ class kandra::app_frontend {
|
|||
|
||||
# Each server does its own fetching of contributor data, since
|
||||
# we don't have a way to synchronize that among several servers.
|
||||
file { '/etc/cron.d/fetch-contributor-data':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/kandra/cron.d/fetch-contributor-data',
|
||||
zulip::cron { 'fetch-contributor-data':
|
||||
hour => '8',
|
||||
minute => '0',
|
||||
command => '/home/zulip/deployments/current/tools/fetch-contributor-data',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,43 +3,29 @@ class kandra::prod_app_frontend_once {
|
|||
include zulip::hooks::push_git_ref
|
||||
include zulip::hooks::zulip_notify
|
||||
|
||||
file { '/etc/cron.d/update-first-visible-message-id':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/calculate-first-visible-message-id',
|
||||
zulip::cron { 'update-first-visible-message-id':
|
||||
hour => '7',
|
||||
minute => '*',
|
||||
manage => 'calculate_first_visible_message_id --lookback-hours 30',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/invoice-plans':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/invoice-plans',
|
||||
zulip::cron { 'invoice-plans':
|
||||
hour => '22',
|
||||
minute => '0',
|
||||
}
|
||||
zulip::cron { 'downgrade-small-realms-behind-on-payments':
|
||||
hour => '17',
|
||||
minute => '0',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/downgrade-small-realms-behind-on-payments':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/downgrade-small-realms-behind-on-payments',
|
||||
zulip::cron { 'check_send_receive_time':
|
||||
hour => '*',
|
||||
minute => '*',
|
||||
command => '/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time --site=https://$(/home/zulip/deployments/current/scripts/get-django-setting NAGIOS_BOT_HOST) >/dev/null',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/check_send_receive_time':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/kandra/cron.d/check_send_receive_time',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/check_user_zephyr_mirror_liveness':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/kandra/cron.d/check_user_zephyr_mirror_liveness',
|
||||
zulip::cron { 'check_user_zephyr_mirror_liveness':
|
||||
hour => '*',
|
||||
minute => '*',
|
||||
command => '/usr/lib/nagios/plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness >/dev/null',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Daily cron job for retention policy - archives existing messages based on the policy
|
||||
# and cleans expired entries from the archive.
|
||||
0 6 * * * zulip /home/zulip/deployments/current/manage.py archive_messages >/dev/null
|
||||
# Daily cron job for cleaning up old, unclaimed attachments and their corresponding files.
|
||||
# Ideally should not run at the same time as the previous job, to avoid races.
|
||||
0 5 * * * zulip /home/zulip/deployments/current/manage.py delete_old_unclaimed_attachments -f >/dev/null
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
0 7 * * * zulip /home/zulip/deployments/current/manage.py calculate_first_visible_message_id --lookback-hours 30
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
30 * * * * zulip /home/zulip/deployments/current/manage.py check_analytics_state
|
|
@ -1,4 +0,0 @@
|
|||
MAILTO=root
|
||||
|
||||
# Clear all expired Django sessions at 10:22 PM every day.
|
||||
22 22 * * * zulip cd /home/zulip/deployments/current && ./manage.py clearsessions
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
0 17 * * * zulip /home/zulip/deployments/current/manage.py downgrade_small_realms_behind_on_payments
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
17 * * * * zulip /home/zulip/deployments/current/manage.py fetch_tor_exit_nodes
|
|
@ -1,5 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
0 22 * * * zulip /home/zulip/deployments/current/manage.py invoice_plans
|
|
@ -1,3 +0,0 @@
|
|||
PATH=/bin:/usr/bin:/usr/local/bin
|
||||
|
||||
0 2 * * * postgres /usr/local/bin/pg_backup_and_purge >/var/log/pg_backup_and_purge.log 2>&1
|
|
@ -1,6 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Cron job to promote users to full members system group.
|
||||
35 * * * * zulip /home/zulip/deployments/current/manage.py promote_new_full_members
|
|
@ -1,7 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Cron job to restart the Zulip server weekly, with the goal of
|
||||
# minimizing the impact of any memory leaks that we might grow.
|
||||
0 6 * * 7 zulip /home/zulip/deployments/current/scripts/restart-server --fill-cache
|
|
@ -1,4 +0,0 @@
|
|||
MAILTO=root
|
||||
|
||||
# Send digest emails once a day. Time is in UTC.
|
||||
0 18 * * * zulip cd /home/zulip/deployments/current && ./manage.py enqueue_digest_emails
|
|
@ -1,6 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Cron job to send zulip update announcements hourly, if there are any.
|
||||
47 * * * * zulip /home/zulip/deployments/current/manage.py send_zulip_update_announcements
|
|
@ -1,6 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Cron job to soft deactivate long term idle users daily.
|
||||
0 5 * * * zulip /home/zulip/deployments/current/manage.py soft_deactivate_users -d >/dev/null
|
|
@ -1,6 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=zulip
|
||||
|
||||
# Run update analytics tables every 5 minutes past the hour
|
||||
5 * * * * zulip /home/zulip/deployments/current/manage.py update_analytics_counts
|
|
@ -245,12 +245,8 @@ class zulip::app_frontend_base {
|
|||
}
|
||||
|
||||
# This cron job does nothing unless RATE_LIMIT_TOR_TOGETHER is enabled.
|
||||
file { '/etc/cron.d/fetch-tor-exit-nodes':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/fetch-tor-exit-nodes',
|
||||
zulip::cron { 'fetch-tor-exit-nodes':
|
||||
minute => '17',
|
||||
}
|
||||
# This was originally added with a typo in the name.
|
||||
file { '/etc/cron.d/fetch-for-exit-nodes':
|
||||
|
|
|
@ -21,67 +21,43 @@ class zulip::app_frontend_once {
|
|||
notify => Service[$zulip::common::supervisor_service],
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/send-digest-emails':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/send-digest-emails',
|
||||
# Every-hour
|
||||
zulip::cron { 'update-analytics-counts':
|
||||
minute => '5',
|
||||
}
|
||||
zulip::cron { 'check-analytics-state':
|
||||
minute => '30',
|
||||
}
|
||||
zulip::cron { 'promote-new-full-members':
|
||||
minute => '35',
|
||||
}
|
||||
zulip::cron { 'send_zulip_update_announcements':
|
||||
minute => '47',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/update-analytics-counts':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/update-analytics-counts',
|
||||
# Daily
|
||||
zulip::cron { 'soft-deactivate-users':
|
||||
hour => '5',
|
||||
minute => '0',
|
||||
manage => 'soft_deactivate_users -d',
|
||||
}
|
||||
zulip::cron { 'delete-old-unclaimed-attachments':
|
||||
hour => '5',
|
||||
minute => '0',
|
||||
manage => 'delete_old_unclaimed_attachments -f',
|
||||
}
|
||||
zulip::cron { 'archive-messages':
|
||||
hour => '6',
|
||||
minute => '0',
|
||||
}
|
||||
zulip::cron { 'send-digest-emails':
|
||||
hour => '18',
|
||||
minute => '0',
|
||||
manage => 'enqueue_digest_emails',
|
||||
}
|
||||
zulip::cron { 'clearsessions':
|
||||
hour => '22',
|
||||
minute => '22',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/check-analytics-state':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/check-analytics-state',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/soft-deactivate-users':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/soft-deactivate-users',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/promote-new-full-members':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/promote-new-full-members',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/archive-messages':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/archive-messages',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/clearsessions':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/clearsessions',
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/send_zulip_update_announcements':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/send_zulip_update_announcements',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
define zulip::cron(
|
||||
String $minute,
|
||||
String $hour = '*',
|
||||
String $dow = '*',
|
||||
String $user = 'zulip',
|
||||
Optional[String] $command = undef,
|
||||
Optional[String] $manage = undef,
|
||||
) {
|
||||
if $command != undef {
|
||||
$run = $command
|
||||
} elsif $manage != undef {
|
||||
$run = "cd /home/zulip/deployments/current/ && ./manage.py ${manage} >/dev/null"
|
||||
} else {
|
||||
$underscores = regsubst($title, '-', '_', 'G')
|
||||
$run = "cd /home/zulip/deployments/current/ && ./manage.py ${underscores} >/dev/null"
|
||||
}
|
||||
file { "/etc/cron.d/${title}":
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
content => template('zulip/cron.template.erb'),
|
||||
}
|
||||
}
|
|
@ -25,12 +25,11 @@ class zulip::postgresql_backups {
|
|||
],
|
||||
}
|
||||
|
||||
file { '/etc/cron.d/pg_backup_and_purge':
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/pg-backup-and-purge',
|
||||
zulip::cron { 'pg_backup_and_purge':
|
||||
hour => '2',
|
||||
minute => '0',
|
||||
command => '/usr/local/bin/pg_backup_and_purge >/var/log/pg_backup_and_purge.log 2>&1',
|
||||
user => 'postgres',
|
||||
require => [
|
||||
File['/var/log/pg_backup_and_purge.log'],
|
||||
File['/usr/local/bin/pg_backup_and_purge'],
|
||||
|
|
|
@ -66,11 +66,10 @@ class zulip::profile::app_frontend {
|
|||
}
|
||||
|
||||
# Restart the server regularly to avoid potential memory leak problems.
|
||||
file { '/etc/cron.d/restart-zulip':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
source => 'puppet:///modules/zulip/cron.d/restart-zulip',
|
||||
zulip::cron { 'restart-zulip':
|
||||
hour => '6',
|
||||
minute => '0',
|
||||
dow => '7',
|
||||
command => '/home/zulip/deployments/current/scripts/restart-server --fill-cache',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
MAILTO=zulip
|
||||
PATH=/usr/local/bin:/usr/bin:/bin
|
||||
SHELL=/bin/bash
|
||||
USER=<%= @user %>
|
||||
|
||||
<%= @minute %> <%= @hour %> * * <%= @dow %> <%= @user %> <%= @run %>
|
||||
|
Loading…
Reference in New Issue