Skip to content

Commit f961a75

Browse files
committed
the first managed worker becomes the global default
1 parent 3c67350 commit f961a75

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/webapp/app/v3/services/worker/workerGroupService.server.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WorkerInstanceGroup, WorkerInstanceGroupType } from "@trigger.dev/datab
22
import { WithRunEngine } from "../baseService.server";
33
import { WorkerGroupTokenService } from "./workerGroupTokenService.server";
44
import { logger } from "~/services/logger.server";
5-
import { makeFlags } from "~/v3/featureFlags.server";
5+
import { makeFlags, makeSetFlags } from "~/v3/featureFlags.server";
66

77
export class WorkerGroupService extends WithRunEngine {
88
private readonly defaultNamePrefix = "worker_group";
@@ -38,6 +38,22 @@ export class WorkerGroupService extends WithRunEngine {
3838
},
3939
});
4040

41+
if (workerGroup.type === WorkerInstanceGroupType.MANAGED) {
42+
const managedCount = await this._prisma.workerInstanceGroup.count({
43+
where: {
44+
type: WorkerInstanceGroupType.MANAGED,
45+
},
46+
});
47+
48+
if (managedCount === 1) {
49+
const setFlag = makeSetFlags(this._prisma);
50+
await setFlag({
51+
key: "defaultWorkerInstanceGroupId",
52+
value: workerGroup.id,
53+
});
54+
}
55+
}
56+
4157
return {
4258
workerGroup,
4359
token,

0 commit comments

Comments
 (0)