Skip to content

Commit eca15ef

Browse files
committed
wordpress: use a systemd timer for running cron tasks
Ref #28.
1 parent af9abdb commit eca15ef

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

modules/wordpress/manifests/site.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,16 @@
221221
notify => Exec['nginx-reload'],
222222
}
223223
}
224+
225+
$cron_minute = fqdn_rand(60, "wordpress-cron-${title}-minute")
226+
$cron_second = fqdn_rand(60, "wordpress-cron-${title}-second")
227+
systemd::timer { "wordpress-cron-${title}":
228+
ensure => present,
229+
description => "Run WordPress cron jobs for ${host}${path}",
230+
user => 'root',
231+
# -k since the certs we use only contain the node FQDN, not the
232+
# sites themselves. this is over localhost so it should be safe
233+
command => "/usr/bin/curl https://${host}${path}wp-cron.php -k --connect-to ::localhost",
234+
interval => ["OnCalendar=*-*-* *:${cron_minute}:${cron_second}"],
235+
}
224236
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<?php
22
define( 'AUTOMATIC_UPDATER_DISABLED', <%= @version ? 'true' : 'false' %> );
3+
define( 'DISABLE_WP_CRON', true );

0 commit comments

Comments
 (0)