Skip to content

Commit

Permalink
Made jobs and runs into nouns
Browse files Browse the repository at this point in the history
  • Loading branch information
samejr committed Aug 24, 2023
1 parent 6979eb6 commit 1fd1d26
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions docs/documentation/guides/jobs/managing.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Managing Jobs"
description: "Managing jobs in your codebase and the dashboard"
description: "Managing Jobs in your codebase and the dashboard"
---

## Disabling jobs
## Disabling Jobs

To prevent a job from processing new runs, you can disable it by setting the `enabled` option:
To prevent a Job from processing new Runs, you can disable it by setting the `enabled` option:

```ts
client.defineJob({
Expand All @@ -15,29 +15,29 @@ client.defineJob({
trigger: eventTrigger({ name: "example.event" }),
enabled: false,
run: async (payload, io, ctx) => {
// your job code here
// your Job code here
},
});
```

If you omit the `enabled` option, it will default to `true`.

The job will only be disabled in environments that have seen the `enabled = false` value. So the job will remain enabled in production until the code with the `enabled = false` is deployed to production.
The Job will only be disabled in environments that have seen the `enabled = false` value. So the Job will remain enabled in production until the code with the `enabled = false` is deployed to production.

<Note>
Currently this is the only way to disable a job. If you'd like to disable a job in the Dashboard,
Currently this is the only way to disable a Job. If you'd like to disable a Job in the Dashboard,
please reach out to us on [Discord](https://discord.gg/kA47vcd8P6) and let us know 👋
</Note>

Once a job is disabled no **new** runs will be created for that job, and it will still be visible in the Dashboard as disabled:
Once a Job is disabled no **new** Runs will be created for that Job, and it will still be visible in the Dashboard as disabled:

![Disabled Job](/images/disabled-job.png)

### In-progress runs
### In-progress Runs

In-progress runs will be allowed to finish, even runs that are currently delayed from a call to `io.wait`. If you'd like to completely stop in-progress runs, you have two options:
In-progress Runs will be allowed to finish, even Runs that are currently delayed from a call to `io.wait`. If you'd like to completely stop in-progress Runs, you have two options:

- Set the `enabled` option to false and then `throw` an error at the top of your job `run` function.
- Set the `enabled` option to false and then `throw` an error at the top of your Job `run` function.

```ts
client.defineJob({
Expand All @@ -52,11 +52,11 @@ client.defineJob({
});
```

- Delete the job from your codebase. This will disable the job as well but also stop in progress runs.
- Delete the Job from your codebase. This will disable the Job as well but also stop in progress Runs.

### Disabling in production with env vars

You can easily disable jobs in production using env vars so you don't have to deploy new code to disable a job.
You can easily disable Jobs in production using env vars so you don't have to deploy new code to disable a Job.

```ts
client.defineJob({
Expand All @@ -66,19 +66,19 @@ client.defineJob({
trigger: eventTrigger({ name: "example.event" }),
enabled: process.env.TRIGGER_JOBS_DISABLED === "true",
run: async (payload, io, ctx) => {
// your job code here
// your Job code here
},
});
```

Then you can disable the job in production by setting the `TRIGGER_JOBS_DISABLED` env var to `"true"`. And removing the env var will re-enable the job.
Then you can disable the Job in production by setting the `TRIGGER_JOBS_DISABLED` env var to `"true"`. And removing the env var will re-enable the Job.

## Deleting jobs
## Deleting Jobs

Once you have disabled a job in all environments, you can delete it from the dashboard by navigating to the Job list page and clicking the "triple-dot" menu next to the job you want to delete:
Once you have disabled a Job in all environments, you can delete it from the dashboard by navigating to the Job list page and clicking the "triple-dot" menu next to the Job you want to delete:

![Job Menu](/images/job-triple-dot-menu.png)

This will bring up a dialog confirming that you want to delete the job and all of its history:
This will bring up a dialog confirming that you want to delete the Job and all of its history:

![Delete Job Dialog](/images/delete-job.png)

0 comments on commit 1fd1d26

Please sign in to comment.