Skip to content

Commit 138abc2

Browse files
committed
refactor: consolidate ClickHouse configuration into single CLICKHOUSE_URL variable
1 parent f0643f7 commit 138abc2

File tree

8 files changed

+21
-25
lines changed

8 files changed

+21
-25
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ REDIS_HOST="localhost"
2121
REDIS_PORT="6379"
2222
REDIS_TLS_DISABLED="true"
2323

24+
# ClickHouse is used for runs replication and analytics queries
25+
CLICKHOUSE_URL=http://default:password@localhost:8123
26+
2427
DEV_OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:3030/otel"
2528
DEV_OTEL_BATCH_PROCESSING_ENABLED="0"
2629

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,7 @@ const EnvironmentSchema = z
10771077
.string()
10781078
.default(process.env.REDIS_TLS_DISABLED ?? "false"),
10791079

1080-
RUN_REPLICATION_CLICKHOUSE_URL: z.string().optional(),
1081-
RUN_REPLICATION_ENABLED: z.string().default("0"),
1080+
RUN_REPLICATION_ENABLED: z.string().default("1"),
10821081
RUN_REPLICATION_SLOT_NAME: z.string().default("task_runs_to_clickhouse_v1"),
10831082
RUN_REPLICATION_PUBLICATION_NAME: z.string().default("task_runs_to_clickhouse_v1_publication"),
10841083
RUN_REPLICATION_MAX_FLUSH_CONCURRENCY: z.coerce.number().int().default(2),

apps/webapp/app/routes/admin.api.v1.runs-replication.create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function action({ request }: ActionFunctionArgs) {
7878

7979
function createRunReplicationService(params: CreateRunReplicationServiceParams) {
8080
const clickhouse = new ClickHouse({
81-
url: env.RUN_REPLICATION_CLICKHOUSE_URL,
81+
url: env.CLICKHOUSE_URL,
8282
name: params.name,
8383
keepAlive: {
8484
enabled: params.keepAliveEnabled,

apps/webapp/app/services/runsReplicationInstance.server.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function initializeRunsReplicationInstance() {
1515
const { DATABASE_URL } = process.env;
1616
invariant(typeof DATABASE_URL === "string", "DATABASE_URL env var not set");
1717

18-
if (!env.RUN_REPLICATION_CLICKHOUSE_URL) {
19-
console.log("🗃️ Runs replication service not enabled");
18+
if (env.RUN_REPLICATION_ENABLED !== "1") {
19+
console.log("🗃️ Runs replication service disabled (RUN_REPLICATION_ENABLED=0)");
2020
return;
2121
}
2222

23-
console.log("🗃️ Runs replication service enabled");
23+
console.log("🗃️ Runs replication service starting");
2424

2525
const clickhouse = new ClickHouse({
26-
url: env.RUN_REPLICATION_CLICKHOUSE_URL,
26+
url: env.CLICKHOUSE_URL,
2727
name: "runs-replication",
2828
keepAlive: {
2929
enabled: env.RUN_REPLICATION_KEEP_ALIVE_ENABLED === "1",
@@ -68,21 +68,19 @@ function initializeRunsReplicationInstance() {
6868
insertStrategy: env.RUN_REPLICATION_INSERT_STRATEGY,
6969
});
7070

71-
if (env.RUN_REPLICATION_ENABLED === "1") {
72-
service
73-
.start()
74-
.then(() => {
75-
console.log("🗃️ Runs replication service started");
76-
})
77-
.catch((error) => {
78-
console.error("🗃️ Runs replication service failed to start", {
79-
error,
80-
});
71+
service
72+
.start()
73+
.then(() => {
74+
console.log("🗃️ Runs replication service started");
75+
})
76+
.catch((error) => {
77+
console.error("🗃️ Runs replication service failed to start", {
78+
error,
8179
});
80+
});
8281

83-
signalsEmitter.on("SIGTERM", service.shutdown.bind(service));
84-
signalsEmitter.on("SIGINT", service.shutdown.bind(service));
85-
}
82+
signalsEmitter.on("SIGTERM", service.shutdown.bind(service));
83+
signalsEmitter.on("SIGINT", service.shutdown.bind(service));
8684

8785
return service;
8886
}

hosting/docker/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ DEV_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8030/otel
6363
CLICKHOUSE_USER=default
6464
CLICKHOUSE_PASSWORD=password
6565
CLICKHOUSE_URL=http://default:password@clickhouse:8123?secure=false
66-
RUN_REPLICATION_CLICKHOUSE_URL=http://default:password@clickhouse:8123
6766

6867
# Docker Registry
6968
# - When testing locally, the default values should be fine

hosting/docker/webapp/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ services:
6666
CLICKHOUSE_LOG_LEVEL: ${CLICKHOUSE_LOG_LEVEL:-info}
6767
# Run replication
6868
RUN_REPLICATION_ENABLED: ${RUN_REPLICATION_ENABLED:-1}
69-
RUN_REPLICATION_CLICKHOUSE_URL: ${RUN_REPLICATION_CLICKHOUSE_URL:-http://default:password@clickhouse:8123}
7069
RUN_REPLICATION_LOG_LEVEL: ${RUN_REPLICATION_LOG_LEVEL:-info}
7170
# Limits
7271
# TASK_PAYLOAD_OFFLOAD_THRESHOLD: 524288 # 512KB

hosting/k8s/helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: trigger
33
description: The official Trigger.dev Helm chart
44
type: application
5-
version: 4.0.4
5+
version: 4.0.5
66
appVersion: v4.0.4
77
home: https://trigger.dev
88
sources:

hosting/k8s/helm/templates/webapp.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,6 @@ spec:
381381
value: {{ .Values.webapp.clickhouse.logLevel | quote }}
382382
- name: RUN_REPLICATION_ENABLED
383383
value: "1"
384-
- name: RUN_REPLICATION_CLICKHOUSE_URL
385-
value: {{ include "trigger-v4.clickhouse.replication.url" . | quote }}
386384
- name: RUN_REPLICATION_LOG_LEVEL
387385
value: {{ .Values.webapp.runReplication.logLevel | quote }}
388386
{{- if not .Values.telemetry.enabled }}

0 commit comments

Comments
 (0)