Skip to content

Commit

Permalink
Merge pull request #2386 from statisticsnorway/HOTFIX-revert-MIM-1707…
Browse files Browse the repository at this point in the history
…-wrap-cron-isMaster

[MIM-1735] Hotfix revert mim 1707 wrap cron is master
  • Loading branch information
Glenruben authored Dec 21, 2023
2 parents 36e6a4a + 6ac11d0 commit 14121ea
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 130 deletions.
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

0 comments on commit 14121ea

Please sign in to comment.