MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / setEnabled

Method setEnabled

src/runtime/adapters/scheduler.ts:441–474  ·  view source on GitHub ↗

* Enable or disable a job and persist.

(
    id: string,
    enabled: boolean,
  )

Source from the content-addressed store, hash-verified

439 };
440 }
441
442 /**
443 * Enable or disable a job and persist.
444 */
445 setEnabled(
446 id: string,
447 enabled: boolean,
448 ): { success: boolean; message: string } {
449 const job = this.jobs.get(id);
450 if (!job) {
451 return { success: false, message: `Job "${id}" not found.` };
452 }
453
454 if (!isRecurringJob(job.config)) {
455 return {
456 success: false,
457 message: `Job "${job.config.name}" does not have a schedule and cannot be enabled or disabled.`,
458 };
459 }
460
461 job.config.enabled = enabled;
462
463 if (enabled && !job.task) {
464 // Create a new cron task for a previously disabled job
465 job.task = this.createCronTask(job.config);
466 } else if (enabled && job.task) {
467 job.task.start();
468 } else if (!enabled && job.task) {
469 job.task.stop();
470 }
471
472 this.persistJobs();
473
474 return {
475 success: true,
476 message: `Job "${job.config.name}" ${enabled ? "enabled" : "disabled"}.`,
477 };

Callers 4

executeFunction · 0.80
handleRequestMethod · 0.80
startMethod · 0.80
scheduler.test.tsFile · 0.80

Calls 5

createCronTaskMethod · 0.95
persistJobsMethod · 0.95
isRecurringJobFunction · 0.85
startMethod · 0.65
stopMethod · 0.65

Tested by

no test coverage detected