@@ -2,7 +2,7 @@ import { SupervisorSession } from "@trigger.dev/core/v3/workers";
22import { SimpleStructuredLogger } from "@trigger.dev/core/v3/utils/structuredLogger" ;
33import { env } from "./env.js" ;
44import { WorkloadServer } from "./workloadServer/index.js" ;
5- import { type WorkloadManager } from "./workloadManager/types.js" ;
5+ import type { WorkloadManagerOptions , WorkloadManager } from "./workloadManager/types.js" ;
66import Docker from "dockerode" ;
77import { z } from "zod" ;
88import { type DequeuedMessage } from "@trigger.dev/core/v3" ;
@@ -50,16 +50,22 @@ class ManagedSupervisor {
5050 console . debug ( "[ManagedSupervisor] Starting up" , { envWithoutSecrets } ) ;
5151 }
5252
53- const workloadApiProtocol = env . TRIGGER_WORKLOAD_API_PROTOCOL ;
54- const workloadApiDomain = env . TRIGGER_WORKLOAD_API_DOMAIN ;
55- const workloadApiPortExternal = env . TRIGGER_WORKLOAD_API_PORT_EXTERNAL ;
56-
5753 if ( this . warmStartUrl ) {
5854 this . logger . log ( "[ManagedWorker] 🔥 Warm starts enabled" , {
5955 warmStartUrl : this . warmStartUrl ,
6056 } ) ;
6157 }
6258
59+ const workloadManagerOptions = {
60+ workloadApiProtocol : env . TRIGGER_WORKLOAD_API_PROTOCOL ,
61+ workloadApiDomain : env . TRIGGER_WORKLOAD_API_DOMAIN ,
62+ workloadApiPort : env . TRIGGER_WORKLOAD_API_PORT_EXTERNAL ,
63+ warmStartUrl : this . warmStartUrl ,
64+ imagePullSecrets : env . KUBERNETES_IMAGE_PULL_SECRETS ?. split ( "," ) ,
65+ heartbeatIntervalSeconds : env . RUNNER_HEARTBEAT_INTERVAL_SECONDS ,
66+ snapshotPollIntervalSeconds : env . RUNNER_SNAPSHOT_POLL_INTERVAL_SECONDS ,
67+ } satisfies WorkloadManagerOptions ;
68+
6369 if ( this . isKubernetes ) {
6470 if ( env . POD_CLEANER_ENABLED ) {
6571 this . logger . log ( "[ManagedWorker] 🧹 Pod cleaner enabled" , {
@@ -92,21 +98,10 @@ class ManagedSupervisor {
9298 }
9399
94100 this . resourceMonitor = new KubernetesResourceMonitor ( createK8sApi ( ) , "" ) ;
95- this . workloadManager = new KubernetesWorkloadManager ( {
96- workloadApiProtocol,
97- workloadApiDomain,
98- workloadApiPort : workloadApiPortExternal ,
99- warmStartUrl : this . warmStartUrl ,
100- imagePullSecrets : env . KUBERNETES_IMAGE_PULL_SECRETS ?. split ( "," ) ,
101- } ) ;
101+ this . workloadManager = new KubernetesWorkloadManager ( workloadManagerOptions ) ;
102102 } else {
103103 this . resourceMonitor = new DockerResourceMonitor ( new Docker ( ) ) ;
104- this . workloadManager = new DockerWorkloadManager ( {
105- workloadApiProtocol,
106- workloadApiDomain,
107- workloadApiPort : workloadApiPortExternal ,
108- warmStartUrl : this . warmStartUrl ,
109- } ) ;
104+ this . workloadManager = new DockerWorkloadManager ( workloadManagerOptions ) ;
110105 }
111106
112107 this . workerSession = new SupervisorSession ( {
0 commit comments