Jobs
Run code once in the background — imports, reports, backfills — and see whether it succeeded.
A Job runs your code once and finishes. Use it for imports, reports, backfills, data migrations, file processing and other batch work. Unlike a Function, nobody waits for a response: you start a run, and Coderunner records whether it succeeded or failed.
To run a Job on a timetable, use a Schedule instead. If your code needs to keep running, use a Service.
Write the handler
A Job uses the same files and handler as a Function, but it doesn't need to return anything:
const handler = async (context, payload) => {
console.log("Starting import", payload);
const count = await importCustomers(payload.source);
console.log(`Imported ${count} customers`);
};
module.exports = { handler };payload is the JSON you start the run with; it can be empty. In .NET, Execute returns Task; in Rust, handler returns (). See the language references.
Deploy it
Go to Build → Coderunner, create a Coderunner with the Job type, upload your ZIP and deploy the new version once it's built.
gf deploy --name customer-import --workload-type jobDeploying doesn't run the Job. It makes it ready to run.
Start a run
| From | How |
|---|---|
| Client Portal | Open the Coderunner and use Run, with an optional JSON payload |
| CLI | gf coderunner run -c customer-import --payload '{"source":"crm"}' |
| API | POST https://platform.groundfloor.cloud/v1/workspaces/{workspace_id}/coderunners/{coderunner_id}/run, with the payload as the JSON body |
A Job also has a Deployment URL, mainly so you can start test runs; call it as you would a Function.
Success and failure
A run finishes as Succeeded or Failed:
- If an error escapes your handler, the run is Failed, and its error details are kept with the execution.
- If you catch an error yourself, the run finishes as Succeeded. That's your choice: handle it, retry, or log it and move on.
Anything your handler prints appears in the Process Log, so log enough to understand a run afterwards. Executions, with their status and error details, are also listed by the API: GET https://platform.groundfloor.cloud/v1/workspaces/{workspace_id}/executions.
Next steps
- Schedules — run this Job automatically.
- Configuration and secrets — settings and secrets your Job can read.
- Logs and troubleshooting — find out why a run failed.