You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
945 B
34 lines
945 B
import schedule from 'node-schedule';
|
|
import { jobPlexFullSync, jobPlexRecentSync } from './plexsync';
|
|
import logger from '../logger';
|
|
|
|
interface ScheduledJob {
|
|
job: schedule.Job;
|
|
name: string;
|
|
}
|
|
|
|
export const scheduledJobs: ScheduledJob[] = [];
|
|
|
|
export const startJobs = (): void => {
|
|
// Run recently added plex sync every 5 minutes
|
|
scheduledJobs.push({
|
|
name: 'Plex Recently Added Sync',
|
|
job: schedule.scheduleJob('0 */10 * * * *', () => {
|
|
logger.info('Starting scheduled job: Plex Recently Added Sync', {
|
|
label: 'Jobs',
|
|
});
|
|
jobPlexRecentSync.run();
|
|
}),
|
|
});
|
|
// Run full plex sync every 6 hours
|
|
scheduledJobs.push({
|
|
name: 'Plex Full Library Sync',
|
|
job: schedule.scheduleJob('0 0 */6 * * *', () => {
|
|
logger.info('Starting scheduled job: Plex Full Sync', { label: 'Jobs' });
|
|
jobPlexFullSync.run();
|
|
}),
|
|
});
|
|
|
|
logger.info('Scheduled jobs loaded', { label: 'Jobs' });
|
|
};
|