feat(pricing): 开发定价方案
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { syncExchangeRate, cleanupPricingPreviews } from './exchange-rate-sync.js';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { S3Client } from '@aws-sdk/client-s3';
|
||||
import { Queue, Worker } from 'bullmq';
|
||||
@@ -460,6 +461,15 @@ async function bootstrap() {
|
||||
'Atlas Worker is ready; consuming transactional-outbox events.',
|
||||
);
|
||||
}
|
||||
// 汇率与预览清理可重复执行,失败保留上次汇率,不影响其他业务队列。
|
||||
const pricingMaintenance=async()=>{
|
||||
await Promise.allSettled([
|
||||
syncExchangeRate(database).catch(()=>console.error('pricing_exchange_rate_sync_failed')),
|
||||
cleanupPricingPreviews(database).catch(()=>console.error('pricing_preview_cleanup_failed')),
|
||||
]);
|
||||
};
|
||||
const pricingTimer=setInterval(()=>void pricingMaintenance(),2*60*60_000);
|
||||
void pricingMaintenance();
|
||||
void bootstrap().catch((error: unknown) => {
|
||||
console.error(
|
||||
'worker_startup_failed',
|
||||
@@ -468,6 +478,7 @@ void bootstrap().catch((error: unknown) => {
|
||||
process.exitCode = 1;
|
||||
});
|
||||
async function shutdown() {
|
||||
clearInterval(pricingTimer);
|
||||
if (dispatcherTimer) clearInterval(dispatcherTimer);
|
||||
if (mediaCleanupTimer) clearInterval(mediaCleanupTimer);
|
||||
if (platformCatalogTimer) clearInterval(platformCatalogTimer);
|
||||
|
||||
Reference in New Issue
Block a user