feat: run jobs on instance creation when run_on_create is enabled
All checks were successful
CI / test (pull_request) Successful in 18s
CI / build-dev (pull_request) Has been skipped

Jobs with run_on_create=true in their config fire automatically
after a new instance is created. Runs fire-and-forget so they don't
delay the 201 response. Option exposed as a checkbox in each job's
detail panel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-28 20:00:45 -04:00
parent c4ebb76deb
commit 817fdaef13
4 changed files with 41 additions and 5 deletions

View File

@@ -129,6 +129,13 @@ export async function runJob(jobId) {
const _intervals = new Map();
export async function runJobsOnCreate() {
for (const job of getJobs()) {
const cfg = JSON.parse(job.config || '{}');
if (cfg.run_on_create) runJob(job.id).catch(e => console.error(`runJobsOnCreate job ${job.id}:`, e));
}
}
export function restartJobs() {
for (const iv of _intervals.values()) clearInterval(iv);
_intervals.clear();