Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

sentry: Configure cron job watching, if sentry.project_dsn is set.

Alex Vandiverf355a081114f
diff --git a/puppet/zulip/manifests/cron.pp b/puppet/zulip/manifests/cron.pp
index f8fdd2bd428..49f48555301 100644
--- a/puppet/zulip/manifests/cron.pp
+++ b/puppet/zulip/manifests/cron.pp
@@ -1,4 +1,5 @@
-
+# @summary Install a cron file into /etc/cron.d
+#
define zulip::cron(
String $minute,
String $hour = '*',
@@ -7,13 +8,23 @@ define zulip::cron(
Optional[String] $command = undef,
Optional[String] $manage = undef,
) {
+ $dsn = zulipconf('sentry', 'project_dsn', '')
+ if $dsn != '' {
+ include zulip::sentry_cli
+ $environment = zulipconf('machine', 'deploy_type', 'development')
+ $sentry = "sentry-cli monitors run -e ${environment} --schedule '${minute} ${hour} * * ${dow}' ${title} -- "
+ $cron_require = [File['/usr/local/bin/sentry-cli']]
+ } else {
+ $sentry = ''
+ $cron_require = []
+ }
if $command != undef {
$run = $command
} elsif $manage != undef {
- $run = "cd /home/zulip/deployments/current/ && ./manage.py ${manage} >/dev/null"
+ $run = "cd /home/zulip/deployments/current/ && ${sentry}./manage.py ${manage} >/dev/null"
} else {
$underscores = regsubst($title, '-', '_', 'G')
- $run = "cd /home/zulip/deployments/current/ && ./manage.py ${underscores} >/dev/null"
+ $run = "cd /home/zulip/deployments/current/ && ${sentry}./manage.py ${underscores} >/dev/null"
}
file { "/etc/cron.d/${title}":
ensure => file,
@@ -21,5 +32,6 @@ define zulip::cron(
group => 'root',
mode => '0644',
content => template('zulip/cron.template.erb'),
+ require => $cron_require,
}
}
diff --git a/puppet/zulip/templates/cron.template.erb b/puppet/zulip/templates/cron.template.erb
index 180bd26c109..a8dee5ebfe3 100644
--- a/puppet/zulip/templates/cron.template.erb
+++ b/puppet/zulip/templates/cron.template.erb
@@ -2,6 +2,9 @@ MAILTO=zulip
PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash
USER=<%= @user %>
+<% if @dsn != '' %>
+SENTRY_DSN=<%= @dsn %>
+<% end %>
<%= @minute %> <%= @hour %> * * <%= @dow %> <%= @user %> <%= @run %>