Skip to content

Commit d876c35

Browse files
committed
Update the default env var concurrency limit and set them when orgs and envs are created
1 parent 6e9c8ab commit d876c35

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

apps/webapp/app/models/organization.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { prisma, PrismaClientOrTransaction } from "~/db.server";
1111
import { createProject } from "./project.server";
1212
import { generate } from "random-words";
1313
import { createApiKeyForEnv, createPkApiKeyForEnv, envSlug } from "./api-key.server";
14+
import { env } from "~/env.server";
1415

1516
export type { Organization };
1617

@@ -62,6 +63,7 @@ export async function createOrganization(
6263
title,
6364
slug: uniqueOrgSlug,
6465
companySize,
66+
maximumConcurrencyLimit: env.DEFAULT_ORG_EXECUTION_CONCURRENCY_LIMIT,
6567
members: {
6668
create: {
6769
userId: userId,
@@ -103,6 +105,7 @@ export async function createEnvironment(
103105
pkApiKey,
104106
shortcode,
105107
autoEnableInternalSources: type !== "DEVELOPMENT",
108+
maximumConcurrencyLimit: env.DEFAULT_ENV_EXECUTION_CONCURRENCY_LIMIT,
106109
organization: {
107110
connect: {
108111
id: organization.id,

apps/webapp/app/v3/services/createBackgroundWorker.server.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export class CreateBackgroundWorkerService extends BaseService {
9191
error:
9292
err instanceof Error
9393
? {
94-
name: err.name,
95-
message: err.message,
96-
stack: err.stack,
97-
}
94+
name: err.name,
95+
message: err.message,
96+
stack: err.stack,
97+
}
9898
: err,
9999
project,
100100
environment,
@@ -141,13 +141,13 @@ export async function createBackgroundTasks(
141141
const concurrencyLimit =
142142
typeof task.queue?.concurrencyLimit === "number"
143143
? Math.max(
144-
Math.min(
145-
task.queue.concurrencyLimit,
146-
environment.maximumConcurrencyLimit,
147-
environment.organization.maximumConcurrencyLimit
148-
),
149-
0
150-
)
144+
Math.min(
145+
task.queue.concurrencyLimit,
146+
environment.maximumConcurrencyLimit,
147+
environment.organization.maximumConcurrencyLimit
148+
),
149+
0
150+
)
151151
: null;
152152

153153
const taskQueue = await prisma.taskQueue.upsert({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "RuntimeEnvironment" ALTER COLUMN "maximumConcurrencyLimit" SET DEFAULT 5;

packages/database/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ model RuntimeEnvironment {
354354
///A memorable code for the environment
355355
shortcode String
356356
357-
maximumConcurrencyLimit Int @default(10)
357+
maximumConcurrencyLimit Int @default(5)
358358
359359
autoEnableInternalSources Boolean @default(true)
360360

0 commit comments

Comments
 (0)