Parcourir la source

Run wp cron jobs every minute

The decision to run every minute was largely based on
https://wpengine.co.uk/support/wp-cron-wordpress-scheduling/

Fixes #17
Girish Ramakrishnan il y a 7 ans
Parent
commit
af1f3fcc9c
3 fichiers modifiés avec 23 ajouts et 1 suppressions
  1. 7 1
      CloudronManifest.json
  2. 13 0
      test/test.js
  3. 3 0
      wp-config.php.template

+ 7 - 1
CloudronManifest.json

@@ -15,7 +15,13 @@
     "mysql": {},
     "localstorage": {},
     "sendmail": {},
-    "ldap": {}
+    "ldap": {},
+    "scheduler": {
+      "wpcron": {
+        "schedule": "*/1 * * * *",
+        "command": "/app/code/wp --allow-root cron event run --due-now"
+      }
+    }
   },
   "tags": [ "blog", "cms", "weblog", "ghost" ],
   "mediaLinks": [

+ 13 - 0
test/test.js

@@ -210,6 +210,19 @@ describe('Application life cycle test', function () {
     it('has correct htaccess', checkHtaccess);
     it('can access permalink', checkPermalink);
 
+    it('runs cron jobs', function (done) {
+        console.log('sleeping for a minute to ensure that cron job has run');
+
+        setTimeout(function () {
+            var logs = execSync('cloudron logs --lines 1000 --app ' + app.id).toString('utf8');
+            if (logs.indexOf('Executed the cron event \'wp_version_check\'') !== -1) return done();
+
+            console.log(logs);
+
+            done(new Error('cron jobs are possibly not running'));
+        }, 60 * 1000);
+    });
+
     it('can restart app', function (done) {
         execSync('cloudron restart --wait');
         done();

+ 3 - 0
wp-config.php.template

@@ -40,6 +40,9 @@ define('WP_PLUGIN_URL', '##APP_ORIGIN/wp-content/plugins');
 define('WP_CONTENT_DIR', '/app/data/wp-content');
 define('WP_PLUGIN_DIR', '/app/data/wp-content/plugins');
 
+// disable built-in page load based cron (https://developer.wordpress.org/plugins/cron/)
+define('DISABLE_WP_CRON', true);
+
 // Enable WP_DEBUG mode
 define('WP_DEBUG', false);