Groundfloor Docs

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:

handler.js
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 job

Deploying doesn't run the Job. It makes it ready to run.

Start a run

FromHow
Client PortalOpen the Coderunner and use Run, with an optional JSON payload
CLIgf coderunner run -c customer-import --payload '{"source":"crm"}'
APIPOST 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, https://invoke.groundfloor.cloud/v1/coderunners/<coderunner-id>, so other code can start runs. POST a JSON object to it with a workspace member's token or an M2M token, as for a Function. It doesn't wait for the run to finish: it answers 202 with the run's ID.

curl -X POST "https://invoke.groundfloor.cloud/v1/coderunners/$CODERUNNER_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"source":"crm"}'
# {"execution_id":"…"}

A Job's URL always needs a token: its invoke access can be Login required (token) or Off, never Public. In the Client Portal, the Job's Invoke address section shows the address and a curl example to copy, and lets you switch between the two; switching to Off asks you to confirm. With gf 0.2.9 or later you can also use gf coderunner invoke-access -c customer-import token (or off, which asks you to confirm). See Change who can call it. Run works whatever the setting. A Job can be started this way up to 10 times a minute by default; the other limits and errors are the same as for 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

On this page