4d01e13a84
* Revert "Revert structured logging 2 (#1240)"
This reverts commit 78ecaeffcb.
* Logging should not be bundled into core shared directory
* making sure observability stuff isnt bundled into frontend
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
26 lines
936 B
TypeScript
26 lines
936 B
TypeScript
import cron from 'node-cron'
|
|
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper'
|
|
import { scheduleExecution } from '@/modules/core/services/taskScheduler'
|
|
import { cleanOrphanedWebhookConfigs } from '@/modules/webhooks/services/cleanup'
|
|
import { activitiesLogger, moduleLogger } from '@/logging/logging'
|
|
|
|
const scheduleWebhookCleanup = () => {
|
|
const cronExpression = '0 4 * * 1'
|
|
return scheduleExecution(cronExpression, 'weeklyWebhookCleanup', async () => {
|
|
activitiesLogger.info('Starting weekly webhooks cleanup')
|
|
await cleanOrphanedWebhookConfigs()
|
|
activitiesLogger.info('Finished cleanup')
|
|
})
|
|
}
|
|
|
|
let scheduledTask: cron.ScheduledTask | null = null
|
|
|
|
export const init: SpeckleModule['init'] = () => {
|
|
moduleLogger.info('🎣 Init webhooks module')
|
|
scheduledTask = scheduleWebhookCleanup()
|
|
}
|
|
|
|
export const shutdown: SpeckleModule['shutdown'] = () => {
|
|
if (scheduledTask) scheduledTask.stop()
|
|
}
|