feat: run jobs on instance creation when run_on_create is enabled
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user