diff --git a/src/config/process.ts b/src/config/process.ts index dc9e430ae8..dad132fccb 100644 --- a/src/config/process.ts +++ b/src/config/process.ts @@ -1,3 +1,5 @@ +import { getCronConfig } from "./yaml" + import { ConfigError } from "./error" type TwilioConfig = { @@ -103,18 +105,21 @@ export const LND_HEALTH_REFRESH_TIME_MS = parseInt( ) export const getLoopConfig = () => { - if (!process.env.LND1_LOOP_TLS) throw new ConfigError("Missing LND1_LOOP_TLS config") - if (!process.env.LND2_LOOP_TLS) throw new ConfigError("Missing LND2_LOOP_TLS config") - if (!process.env.LND1_LOOP_MACAROON) - throw new ConfigError("Missing LND1_LOOP_MACAROON config") - if (!process.env.LND2_LOOP_MACAROON) - throw new ConfigError("Missing LND2_LOOP_MACAROON config") - return { - lnd1LoopTls: process.env.LND1_LOOP_TLS, - lnd1LoopMacaroon: process.env.LND1_LOOP_MACAROON as Macaroon, - lnd2LoopTls: process.env.LND2_LOOP_TLS, - lnd2LoopMacaroon: process.env.LND2_LOOP_MACAROON as Macaroon, + if (getCronConfig().swapEnabled) { + if (!process.env.LND1_LOOP_TLS) throw new ConfigError("Missing LND1_LOOP_TLS config") + if (!process.env.LND2_LOOP_TLS) throw new ConfigError("Missing LND2_LOOP_TLS config") + if (!process.env.LND1_LOOP_MACAROON) + throw new ConfigError("Missing LND1_LOOP_MACAROON config") + if (!process.env.LND2_LOOP_MACAROON) + throw new ConfigError("Missing LND2_LOOP_MACAROON config") + return { + lnd1LoopTls: process.env.LND1_LOOP_TLS, + lnd1LoopMacaroon: process.env.LND1_LOOP_MACAROON as Macaroon, + lnd2LoopTls: process.env.LND2_LOOP_TLS, + lnd2LoopMacaroon: process.env.LND2_LOOP_MACAROON as Macaroon, + } } + throw new ConfigError("getLoopConfig() was called though swapEnabled is false") } export const getKratosMasterPhonePassword = () => { diff --git a/src/services/tracing.ts b/src/services/tracing.ts index 5eb9ed4ffd..cbd1eef2dc 100644 --- a/src/services/tracing.ts +++ b/src/services/tracing.ts @@ -187,7 +187,7 @@ registerInstrumentations({ const provider = new NodeTracerProvider({ resource: Resource.default().merge( new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: tracingConfig.tracingServiceName, + [SemanticResourceAttributes.SERVICE_NAME]: tracingConfig?.tracingServiceName, }), ), }) @@ -209,8 +209,8 @@ class SpanProcessorWrapper extends SimpleSpanProcessor { provider.addSpanProcessor( new SpanProcessorWrapper( new JaegerExporter({ - host: tracingConfig.jaegerHost, - port: tracingConfig.jaegerPort, + host: tracingConfig?.jaegerHost, + port: tracingConfig?.jaegerPort, }), ), ) @@ -218,7 +218,7 @@ provider.addSpanProcessor( provider.register() export const tracer = trace.getTracer( - tracingConfig.tracingServiceName, + tracingConfig?.tracingServiceName, process.env.COMMITHASH || "dev", ) export const addAttributesToCurrentSpan = (attributes: Attributes) => {