Maintenance Scripts

Daily Maintenance

daily_maint.php is run once per day. It is never called directly; hourly_maint.php calls it when it runs during hour 0. This is important, because hourly_maint.php holds a semaphore that prevents the delivery engine from stepping on the shared memory space while the maintenance code is running.

Check for underdelivery

The script looks through all the creatives in the DailyTargets table (remember that this script only runs at midnight, and thus it is looking at the daily targets for yesterday, after the hour 23 results have been tabulated by hourly_maint.php). For any creatives which have specific impression targets, it checks the number remaining. If that number is greater than 0, mail will be sent to the administrator.

The administrator's email is in the OASISPrefs table as "AdminEmail".

Compute daily targets

Under the protection of a lock, the DailyTargets table is emptied and reloaded. The creatives' targets are calculated in a specific order. First, all campaigns with ImpressionsGuaranteed - ImpressionsDelivered > 0 are scanned. A daily target for the campaign is generated, and then this target is split among the campaign's creatives. Creatives with non-zero ImpressionsGuaranteed get an appropriate number of impressions to meet their targets (unless that number would exceed those allotted to the campaign, in which case, the creative only gets the number allotted to the campaign). Creatives which have ImpressionsGuaranteed = 0 get a share of the Campaign's impressions proportional to their Weight.

Finally, campaigns with no impression targets are scanned. Their creatives are inserted into the DailyTargets table with Target = 0, and

Weight = int(Campaigns.Weight * (Creatives.Weight / Sum of all campaign creatives' weights) * 100)

This multiplication preserves the relative weights of creatives within a campaign and the relative weights of campaigns to each other.

This might be a no-brainer, but it is important to note that as campaigns and creatives are scheduled, only those scheduled to run on today's day of the week will be scheduled. For example, if the script is running on a Monday, only campaigns and creatives slated to run on Mondays will be examined.

Load shared memory

Finally, the creatives which are scheduled to run today are loaded into shared memory. Here is where the semaphore acquired by hourly_maint.php is really important. The Creative Content and Creative Clickthrough shared memory segments are wiped clean (thus, if the delivery engine were running, it would experience severe trauma). For each creative in the HourlyTargets table, the Contents, ClickthroughURL, and other relevant fields (Redirect, MIMEType, Animated) are loaded into the two shared memory segments.