fix(web): normalize log schema and analytics cron
parent
68aaf4e299
commit
53acafb3d6
@ -1,6 +1,6 @@
|
||||
# Edit the PHP binary and project path for your deployment before installing.
|
||||
# VM service-period and traffic enforcement is the virt-cloud-lifecycle systemd service, not cron.
|
||||
# No account expiry, proxy-node or automatic record-deletion jobs.
|
||||
0 6 * * * /usr/bin/php /home/www/virt-cloud/web/xcat backupJob >> /home/www/virt-cloud/web/storage/logs/database_backup.log 2>&1
|
||||
* * * * * /usr/bin/php /home/www/virt-cloud/web/xcat usdtScanJob 50 >> /home/www/virt-cloud/web/storage/logs/usdt_scan.log 2>&1
|
||||
*/5 * * * * /usr/bin/php /home/www/virt-cloud/web/xcat siteAnalyticsJob 2 >> /home/www/virt-cloud/web/storage/logs/site_analytics.log 2>&1
|
||||
0 6 * * * /usr/bin/php /home/virt-cloud/web/xcat backupJob >> /home/virt-cloud/web/storage/logs/database_backup.log 2>&1
|
||||
* * * * * /usr/bin/php /home/virt-cloud/web/xcat usdtScanJob 50 >> /home/virt-cloud/web/storage/logs/usdt_scan.log 2>&1
|
||||
*/5 * * * * /usr/bin/php /home/virt-cloud/web/xcat siteAnalyticsJob 2 >> /home/virt-cloud/web/storage/logs/site_analytics.log 2>&1
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$schema = file_get_contents($root . '/sql/user_log.sql');
|
||||
$crontab = file_get_contents($root . '/crontab');
|
||||
|
||||
$assert = static function (bool $condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$settingBlock = '';
|
||||
if (preg_match(
|
||||
'/ALTER TABLE `setting`(?<body>.*?);/s',
|
||||
(string) $schema,
|
||||
$matches
|
||||
) === 1) {
|
||||
$settingBlock = (string) $matches['body'];
|
||||
}
|
||||
$assert($settingBlock !== '', 'setting indexes are missing');
|
||||
$assert(
|
||||
substr_count($settingBlock, 'UNIQUE KEY') === 1,
|
||||
'setting must have exactly one unique key index'
|
||||
);
|
||||
$assert(
|
||||
str_contains($settingBlock, 'UNIQUE KEY `uniq_setting_key` (`key`)'),
|
||||
'setting unique key index must use the canonical name'
|
||||
);
|
||||
$assert(
|
||||
!str_contains((string) $schema, 'idx_setting_'),
|
||||
'legacy duplicate setting indexes must not remain in fresh schema'
|
||||
);
|
||||
|
||||
$expectedAnalytics = '*/5 * * * * /usr/bin/php '
|
||||
. '/home/virt-cloud/web/xcat siteAnalyticsJob 2 '
|
||||
. '>> /home/virt-cloud/web/storage/logs/site_analytics.log 2>&1';
|
||||
$assert(
|
||||
str_contains((string) $crontab, $expectedAnalytics),
|
||||
'site analytics must retain the original five-minute cron schedule'
|
||||
);
|
||||
$assert(
|
||||
!str_contains((string) $crontab, '/home/www/virt-cloud'),
|
||||
'crontab must use the documented deployment root'
|
||||
);
|
||||
|
||||
echo "Log schema and crontab contract test passed\n";
|
||||
Loading…
Reference in New Issue