MCPcopy
hub / github.com/xpf0000/FlyEnv / apply

Method apply

src/fork/module/Cron/SystemScheduler.ts:47–84  ·  view source on GitHub ↗
(job: CronJob)

Source from the content-addressed store, hash-verified

45 }
46
47 async apply(job: CronJob): Promise<CronJob> {
48 const scheduler = this.platformScheduler()
49
50 if (!job.enabled) {
51 await scheduler?.remove(job.id)
52 return {
53 ...job,
54 systemRegistered: false,
55 systemTaskName: undefined,
56 systemError: undefined
57 }
58 }
59
60 assertPortableCronExpression(job.schedule)
61 if (!scheduler) {
62 throw new Error('Cron system scheduler is not supported on this platform')
63 }
64
65 try {
66 await mkdirp(this.cronRoot)
67 await scheduler.remove(job.id)
68 await scheduler.install(job)
69
70 return {
71 ...job,
72 systemRegistered: true,
73 systemTaskName: systemTaskName(job.id),
74 systemError: undefined
75 }
76 } catch (e: any) {
77 return {
78 ...job,
79 systemRegistered: false,
80 systemTaskName: systemTaskName(job.id),
81 systemError: e?.message || `${e}`
82 }
83 }
84 }
85}

Callers 6

oFunction · 0.80
php-parser.min.jsFile · 0.80
iFunction · 0.80
addCronJobMethod · 0.80
updateCronJobMethod · 0.80
toggleCronJobMethod · 0.80

Calls 5

platformSchedulerMethod · 0.95
systemTaskNameFunction · 0.90
removeMethod · 0.65
installMethod · 0.65

Tested by

no test coverage detected