Skip to content

Commit ea07b62

Browse files
committed
update admin worker route
1 parent 756973f commit ea07b62

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

apps/supervisor/README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88
api_url=http://localhost:3030
99
wg_name=my-worker
1010

11-
# edit these
11+
# edit this
1212
admin_pat=tr_pat_...
13-
project_id=clsw6q8wz...
1413

1514
curl -sS \
1615
-X POST \
1716
"$api_url/admin/api/v1/workers" \
1817
-H "Authorization: Bearer $admin_pat" \
1918
-H "Content-Type: application/json" \
20-
-d "{
21-
\"name\": \"$wg_name\",
22-
\"makeDefault\": true,
23-
\"projectId\": \"$project_id\"
24-
}"
19+
-d "{\"name\": \"$wg_name\"}"
2520
```
2621

2722
2. Create `.env` and set the worker token
@@ -47,3 +42,26 @@ pnpm exec trigger deploy --self-hosted
4742
# The additional network flag is required on linux
4843
pnpm exec trigger deploy --self-hosted --network host
4944
```
45+
46+
## Additional worker groups
47+
48+
When adding more worker groups you might also want to make them the default for a specific project. This will allow you to test it without having to change the global default:
49+
50+
```sh
51+
api_url=http://localhost:3030
52+
wg_name=my-worker
53+
54+
# edit these
55+
admin_pat=tr_pat_...
56+
project_id=clsw6q8wz...
57+
58+
curl -sS \
59+
-X POST \
60+
"$api_url/admin/api/v1/workers" \
61+
-H "Authorization: Bearer $admin_pat" \
62+
-H "Content-Type: application/json" \
63+
-d "{
64+
\"name\": \"$wg_name\",
65+
\"makeDefaultForProjectId\": \"$project_id\"
66+
}"
67+
```

apps/webapp/app/routes/admin.api.v1.workers.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { WorkerGroupService } from "~/v3/services/worker/workerGroupService.serv
77
const RequestBodySchema = z.object({
88
name: z.string().optional(),
99
description: z.string().optional(),
10-
projectId: z.string().optional(),
11-
makeDefault: z.boolean().optional(),
10+
makeDefaultForProjectId: z.string().optional(),
1211
});
1312

1413
export async function action({ request }: ActionFunctionArgs) {
@@ -35,22 +34,21 @@ export async function action({ request }: ActionFunctionArgs) {
3534

3635
try {
3736
const rawBody = await request.json();
38-
const { name, description, projectId, makeDefault } = RequestBodySchema.parse(rawBody ?? {});
37+
const { name, description, makeDefaultForProjectId } = RequestBodySchema.parse(rawBody ?? {});
3938

4039
const service = new WorkerGroupService();
4140
const { workerGroup, token } = await service.createWorkerGroup({
4241
name,
4342
description,
4443
});
4544

46-
if (makeDefault && projectId) {
45+
if (makeDefaultForProjectId) {
4746
await prisma.project.update({
4847
where: {
49-
id: projectId,
48+
id: makeDefaultForProjectId,
5049
},
5150
data: {
5251
defaultWorkerGroupId: workerGroup.id,
53-
engine: "V2",
5452
},
5553
});
5654
}

0 commit comments

Comments
 (0)