Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIM-1735] Hotfix revert mim 1707 wrap cron is master #2386

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gradle Project settings
projectName = mimir
version = 2.1.0
version = 2.1.1

# XP App values
appDisplayName = Mimir application
Expand Down
258 changes: 129 additions & 129 deletions src/main/resources/lib/ssb/cron/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,20 @@ export function runOnMasterOnly(task: () => void): void {
export function setupCronJobs(): void {
run(createUserContext, setupCronJobUser)

// clear specific cache once an hour
const clearCacheCron: string =
app.config && app.config['ssb.cron.clearCacheCron'] ? app.config['ssb.cron.clearCacheCron'] : '01 * * * *'
// setup dataquery cron job
const dataqueryCron: string =
app.config && app.config['ssb.cron.dataquery'] ? app.config['ssb.cron.dataquery'] : '0 15 * * *'
schedule({
name: 'clear cache',
cron: clearCacheCron,
name: 'Data from datasource endpoints',
cron: dataqueryCron,
callback: () => {
clearPartFromPartCache('kpiCalculator')
clearPartFromPartCache('pifCalculator')
clearPartFromPartCache('bkibolCalculator')
clearPartFromPartCache('husleieCalculator')
clearPartFromPartCache('omStatistikken')
clearPartFromPartCache('releasedStatistics')
clearPartFromPartCache('upcomingReleases')
clearPartFromPartCache('articleList')
clearPartFromPartCache('relatedFactPage')
clearPartFromPartCache('archiveAllPublications-nb')
clearPartFromPartCache('archiveAllPublications-en')
libScheduleTestLog('dataqueryCronTest', dataqueryCron)
runOnMasterOnly(job)
},
context: cronContext,
})
// using config in https://github.com/statisticsnorway/mimir-config/blob/master/prod/mimir.cfg as base
// libScheduleTest({ name: 'dataqueryCronTest', cron: '03 08 * * *', timeZone: 'Europe/Oslo' }, dataqueryCron)

// clear calculator parts cache cron
const clearCalculatorPartsCacheCron: string =
Expand All @@ -196,133 +189,140 @@ export function setupCronJobs(): void {
},
context: cronContext,
})
// libScheduleTest(
// { name: 'clearCalculatorCronTest', cron: '15 08 * * *', timeZone: 'Europe/Oslo' },
// clearCalculatorPartsCacheCron
// )

if (isMaster()) {
// setup dataquery cron job
const dataqueryCron: string =
app.config && app.config['ssb.cron.dataquery'] ? app.config['ssb.cron.dataquery'] : '0 15 * * *'
schedule({
name: 'Data from datasource endpoints',
cron: dataqueryCron,
callback: () => {
libScheduleTestLog('dataqueryCronTest', dataqueryCron)
job()
},
context: cronContext,
})
// using config in https://github.com/statisticsnorway/mimir-config/blob/master/prod/mimir.cfg as base
libScheduleTest({ name: 'dataqueryCronTest', cron: '03 08 * * *', timeZone: 'Europe/Oslo' }, dataqueryCron)
// and setup a cron for periodic executions in the future
const statregCron: string =
app.config && app.config['ssb.cron.statreg'] ? app.config['ssb.cron.statreg'] : '30 14 * * *'
schedule({
name: 'StatReg Periodic Refresh',
cron: statregCron,
callback: () => {
libScheduleTestLog('statregRefreshCronTest', statregCron)
runOnMasterOnly(statRegJob)
},
context: cronContext,
})
// libScheduleTest({ name: 'statregRefreshCronTest', cron: '05 8 * * *', timeZone: 'Europe/Oslo' }, statregCron)

// and setup a cron for periodic executions in the future
const statregCron: string =
app.config && app.config['ssb.cron.statreg'] ? app.config['ssb.cron.statreg'] : '30 14 * * *'
schedule({
name: 'StatReg Periodic Refresh',
cron: statregCron,
callback: () => {
libScheduleTestLog('statregRefreshCronTest', statregCron)
statRegJob()
},
context: cronContext,
})
libScheduleTest({ name: 'statregRefreshCronTest', cron: '05 8 * * *', timeZone: 'Europe/Oslo' }, statregCron)
// Update repo no.ssb.statistic.variant
const updateStatisticRepoCron: string =
app.config && app.config['ssb.cron.updateStatisticRepo'] ? app.config['ssb.cron.updateStatisticRepo'] : '0 7 * * *'

// Update repo no.ssb.statistic.variant
const updateStatisticRepoCron: string =
app.config && app.config['ssb.cron.updateStatisticRepo']
? app.config['ssb.cron.updateStatisticRepo']
: '0 7 * * *'
schedule({
name: 'Update no.ssb.statistics Repo',
cron: updateStatisticRepoCron,
callback: () => {
libScheduleTestLog('statregUpdateCronTest', updateStatisticRepoCron)
runOnMasterOnly(createOrUpdateStatisticsRepo)
},
context: cronContext,
})
// libScheduleTest(
// { name: 'statregUpdateCronTest', cron: '0 8 * * *', timeZone: 'Europe/Oslo' },
// updateStatisticRepoCron
// )

schedule({
name: 'Update no.ssb.statistics Repo',
cron: updateStatisticRepoCron,
callback: () => {
libScheduleTestLog('statregUpdateCronTest', updateStatisticRepoCron)
createOrUpdateStatisticsRepo()
},
context: cronContext,
})
libScheduleTest(
{ name: 'statregUpdateCronTest', cron: '0 8 * * *', timeZone: 'Europe/Oslo' },
updateStatisticRepoCron
)
const deleteExpiredEventLogCron: string =
app.config && app.config['ssb.cron.deleteLogs'] ? app.config['ssb.cron.deleteLogs'] : '45 13 * * *'
schedule({
name: 'Delete expired event logs for queries',
cron: deleteExpiredEventLogCron,
callback: () => {
libScheduleTestLog('deleteExpireCronTest', deleteExpiredEventLogCron)
runOnMasterOnly(deleteExpiredEventLogsForQueries)
},
context: cronContext,
})
// libScheduleTest(
// { name: 'deleteExpireCronTest', cron: '20 15 * * *', timeZone: 'Europe/Oslo' },
// deleteExpiredEventLogCron
// )

const deleteExpiredEventLogCron: string =
app.config && app.config['ssb.cron.deleteLogs'] ? app.config['ssb.cron.deleteLogs'] : '45 13 * * *'
if (app.config && app.config['ssb.mock.enable'] === 'true') {
const updateUnpublishedMockCron: string =
app.config && app.config['ssb.cron.updateUnpublishedMock']
? app.config['ssb.cron.updateUnpublishedMock']
: '0 04 * * *'
schedule({
name: 'Delete expired event logs for queries',
cron: deleteExpiredEventLogCron,
callback: () => {
libScheduleTestLog('deleteExpireCronTest', deleteExpiredEventLogCron)
deleteExpiredEventLogsForQueries()
},
name: 'Update unpublished mock tbml',
cron: updateUnpublishedMockCron,
callback: () => runOnMasterOnly(updateUnpublishedMockTbml),
context: cronContext,
})
libScheduleTest(
{ name: 'deleteExpireCronTest', cron: '20 15 * * *', timeZone: 'Europe/Oslo' },
deleteExpiredEventLogCron
)
}

if (app.config && app.config['ssb.mock.enable'] === 'true') {
const updateUnpublishedMockCron: string =
app.config && app.config['ssb.cron.updateUnpublishedMock']
? app.config['ssb.cron.updateUnpublishedMock']
: '0 04 * * *'
schedule({
name: 'Update unpublished mock tbml',
cron: updateUnpublishedMockCron,
callback: () => updateUnpublishedMockTbml(),
context: cronContext,
})
}
// push news to rss feed
const pushRssNewsCron: string =
app.config && app.config['ssb.cron.pushRssNews'] ? app.config['ssb.cron.pushRssNews'] : '02 06 * * *'
schedule({
name: 'Push RSS news',
cron: pushRssNewsCron,
callback: () => {
libScheduleTestLog('pushRssNewsCronTest', pushRssNewsCron)
runOnMasterOnly(pushRssNewsJob)
},
context: cronContext,
})
// libScheduleTest({ name: 'pushRssNewsCronTest', cron: '01 08 * * *', timeZone: 'Europe/Oslo' }, pushRssNewsCron)

// push news to rss feed
const pushRssNewsCron: string =
app.config && app.config['ssb.cron.pushRssNews'] ? app.config['ssb.cron.pushRssNews'] : '02 06 * * *'
schedule({
name: 'Push RSS news',
cron: pushRssNewsCron,
callback: () => {
libScheduleTestLog('pushRssNewsCronTest', pushRssNewsCron)
pushRssNewsJob()
},
context: cronContext,
})
libScheduleTest({ name: 'pushRssNewsCronTest', cron: '01 08 * * *', timeZone: 'Europe/Oslo' }, pushRssNewsCron)
// clear specific cache once an hour
const clearCacheCron: string =
app.config && app.config['ssb.cron.clearCacheCron'] ? app.config['ssb.cron.clearCacheCron'] : '01 * * * *'
schedule({
name: 'clear cache',
cron: clearCacheCron,
callback: () => {
clearPartFromPartCache('kpiCalculator')
clearPartFromPartCache('pifCalculator')
clearPartFromPartCache('bkibolCalculator')
clearPartFromPartCache('husleieCalculator')
clearPartFromPartCache('omStatistikken')
clearPartFromPartCache('releasedStatistics')
clearPartFromPartCache('upcomingReleases')
clearPartFromPartCache('articleList')
clearPartFromPartCache('relatedFactPage')
clearPartFromPartCache('archiveAllPublications-nb')
clearPartFromPartCache('archiveAllPublications-en')
},
context: cronContext,
})

// Update SDDS tables
const updateSDDSTablesCron: string =
app.config && app.config['ssb.cron.updateSDDSTables'] ? app.config['ssb.cron.updateSDDSTables'] : '01 09 * * *'
schedule({
name: 'Update SDDS tables',
cron: updateSDDSTablesCron,
callback: () => {
libScheduleTestLog('updateSDDSCronTest', updateSDDSTablesCron)
updateSDDSTables()
},
context: cronContext,
})
libScheduleTest({ name: 'updateSDDSCronTest', cron: '01 09 * * *', timeZone: 'Europe/Oslo' }, updateSDDSTablesCron)
// Update SDDS tables
const updateSDDSTablesCron: string =
app.config && app.config['ssb.cron.updateSDDSTables'] ? app.config['ssb.cron.updateSDDSTables'] : '01 09 * * *'
schedule({
name: 'Update SDDS tables',
cron: updateSDDSTablesCron,
callback: () => {
libScheduleTestLog('updateSDDSCronTest', updateSDDSTablesCron)
runOnMasterOnly(updateSDDSTables)
},
context: cronContext,
})
// libScheduleTest({ name: 'updateSDDSCronTest', cron: '01 09 * * *', timeZone: 'Europe/Oslo' }, updateSDDSTablesCron)

const datasetPublishCron: string =
app.config && app.config['ssb.cron.publishDataset'] ? app.config['ssb.cron.publishDataset'] : '50 05 * * *'
const datasetPublishCron: string =
app.config && app.config['ssb.cron.publishDataset'] ? app.config['ssb.cron.publishDataset'] : '50 05 * * *'

log.info('Run old datasetPublishCron cron-library')
// publish dataset cron job
schedule({
name: 'Dataset publish',
cron: datasetPublishCron,
callback: () => {
libScheduleTestLog('datasetPublishCronTest', datasetPublishCron)
publishDataset()
},
context: cronContext,
})
libScheduleTest(
{ name: 'datasetPublishCronTest', cron: '50 07 * * *', timeZone: 'Europe/Oslo' },
datasetPublishCron
)
log.info('Run old datasetPublishCron cron-library')
// publish dataset cron job
schedule({
name: 'Dataset publish',
cron: datasetPublishCron,
callback: () => {
libScheduleTestLog('datasetPublishCronTest', datasetPublishCron)
runOnMasterOnly(publishDataset)
},
context: cronContext,
})
// libScheduleTest({ name: 'datasetPublishCronTest', cron: '50 07 * * *', timeZone: 'Europe/Oslo' }, datasetPublishCron)

// Task
if (isMaster()) {
const timezone: string =
app.config && app.config['ssb.cron.timezone'] ? app.config['ssb.cron.timezone'] : 'Europe/Oslo'

Expand Down