MCPcopy Create free account
hub / github.com/vercel/vercel / getServiceCrons

Function getServiceCrons

packages/python/src/crons.ts:58–120  ·  view source on GitHub ↗
(opts: {
  service?: {
    type?: ServiceType;
    trigger?: JobTrigger;
    name?: string;
    schedule?: string | string[];
  };
  entrypoint?: string;
  rawEntrypoint?: string;
  handlerFunction?: string;
  pythonBin: string;
  env: NodeJS.ProcessEnv;
  workPath: string;
})

Source from the content-addressed store, hash-verified

56 * For "<dynamic>" schedules, calls a Python function via subprocess.
57 */
58export async function getServiceCrons(opts: {
59 service?: {
60 type?: ServiceType;
61 trigger?: JobTrigger;
62 name?: string;
63 schedule?: string | string[];
64 };
65 entrypoint?: string;
66 rawEntrypoint?: string;
67 handlerFunction?: string;
68 pythonBin: string;
69 env: NodeJS.ProcessEnv;
70 workPath: string;
71}): Promise<ServiceCronEntry[] | undefined> {
72 const { service, entrypoint, rawEntrypoint, handlerFunction } = opts;
73 const isScheduledService = !!service && isScheduleTriggeredService(service);
74
75 if (
76 !isScheduledService ||
77 !service.name ||
78 (typeof service.schedule !== 'string' && !Array.isArray(service.schedule))
79 ) {
80 return undefined;
81 }
82
83 const cronEntrypoint = entrypoint || rawEntrypoint;
84 if (!cronEntrypoint) {
85 throw new NowBuildError({
86 code: 'PYTHON_CRON_NO_ENTRYPOINT',
87 message: 'Cron service is missing an entrypoint.',
88 });
89 }
90
91 if (service.schedule === DYNAMIC_SCHEDULE) {
92 return getServiceCronsDynamic({
93 serviceName: service.name,
94 cronEntrypoint,
95 handlerFunction,
96 pythonBin: opts.pythonBin,
97 env: opts.env,
98 workPath: opts.workPath,
99 });
100 }
101
102 // Static schedule path
103 const cronPath = getInternalServiceCronPath(
104 service.name,
105 cronEntrypoint,
106 handlerFunction || 'cron'
107 );
108 const moduleName = entrypointToModule(cronEntrypoint);
109 const resolvedHandler = handlerFunction
110 ? `${moduleName}:${handlerFunction}`
111 : moduleName;
112 const schedules = Array.isArray(service.schedule)
113 ? service.schedule
114 : [service.schedule];
115 return schedules.map(schedule => ({

Callers 4

unit.test.tsFile · 0.90
buildFunction · 0.90
startDevServerFunction · 0.90

Calls 4

entrypointToModuleFunction · 0.90
getServiceCronsDynamicFunction · 0.85

Tested by

no test coverage detected