It would be very helpful if multisite manager could run all the created drupal sites' cron jobs when the "master site's" cron was run.

Comments

dwarner’s picture

Version: 5.x-0.9-3 » 5.x-0.9-4
StatusFileSize
new2.38 KB

Here's a first stab at running each sub-site's cron jobs. I couldn't figure out how to only switch databases/prefixes and just call drupal_run_cron(); it seemed like drupal had the 'cron_semaphore' variable cached and wouldn't run the cron jobs for the sub-sites. Currently it's implemented as a call to each sub-site's cron.php page using drupal_http_request().

I'd like to add the feature where an admin can set the default value for whether to run sub-sites' cron jobs and add the option to each drupal site, but that will require an update script as well. Let me know what you think.

schuyler1d’s picture

Status: Active » Needs work

The problem with calling it through the url is that there's little likelikhood that the process will be logged in to all of the websites.

Without this fixed, it will still be difficult to use drupal_cron_run. We'll probably need a test function to see whether it's broken or not before trying to run it.

dwarner’s picture

New patch that adds an option for running drupal sites' cron jobs globally and per-drupal-site (with update script).

I attempted to use drupal_run_cron() initially but it didn't work out well for me. I agree that calling it through the URL is definitely not the most ideal, but I'm not sure what other methods are available if drupal_run_cron() is out. You're much more familiar with switching the DBs to do the install work, so if you have any suggestions on things to try here, I'm open to suggestions.

The only thing I can think of that might help is increasing the set_time_limit() similar to what drupal_run_cron() does for each time through the loop running drupal sites' cron jobs.

schuyler1d’s picture

Status: Needs work » Fixed

ok, I committed your changes, fixing two bugs.
1. _multisite_manager_node_url($node) needed 'global $base_url;' to work properly
2. Your test for >=400 wasn't triggering because drupal_http_request() is too clever by half and doesn't include the response code if it's an error, so I just test for $result->error

I came around the URL method you're doing, since I realized that cron.php isn't protected by any auth. I documented this a little bit in my commit inside the hook_cron() method. You can pull from HEAD or d/l 0.9.5

dwarner’s picture

Status: Fixed » Closed (fixed)

Looks good to me; thanks for merging!