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

@@ -5,7 +5,7 @@ import {
getConfig, setConfig, getJobs, getJob, updateJob, getJobRuns,
getAllJobs, getAllJobRuns, importJobs,
} from './db.js';
import { runJob, restartJobs } from './jobs.js';
import { runJob, restartJobs, runJobsOnCreate } from './jobs.js';
export const router = Router();
@@ -102,6 +102,7 @@ router.post('/instances', (req, res) => {
createInstance(data);
const created = getInstance(data.vmid);
res.status(201).json(created);
runJobsOnCreate().catch(() => {});
} catch (e) {
handleDbError('POST /api/instances', e, res);
}