fix env loading in worker

This commit is contained in:
k00b 2024-08-28 09:34:24 -05:00
parent 17da24ce24
commit b6e4f97668
2 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,6 @@
// environment variables are loaded from files and imports run before the rest of the code
import './loadenv.js'
import PgBoss from 'pg-boss' import PgBoss from 'pg-boss'
import nextEnv from '@next/env'
import createPrisma from '@/lib/create-prisma.js' import createPrisma from '@/lib/create-prisma.js'
import { import {
autoDropBolt11s, checkInvoice, checkPendingDeposits, checkPendingWithdrawals, autoDropBolt11s, checkInvoice, checkPendingDeposits, checkPendingWithdrawals,
@ -34,11 +35,8 @@ import {
import { thisDay } from './thisDay.js' import { thisDay } from './thisDay.js'
import { isServiceEnabled } from '@/lib/sndev.js' import { isServiceEnabled } from '@/lib/sndev.js'
const { loadEnvConfig } = nextEnv
const { ApolloClient, HttpLink, InMemoryCache } = apolloClient const { ApolloClient, HttpLink, InMemoryCache } = apolloClient
loadEnvConfig('.', process.env.NODE_ENV === 'development')
async function work () { async function work () {
const boss = new PgBoss(process.env.DATABASE_URL) const boss = new PgBoss(process.env.DATABASE_URL)
const models = createPrisma({ const models = createPrisma({

3
worker/loadenv.js Normal file
View File

@ -0,0 +1,3 @@
import nextEnv from '@next/env'
const { loadEnvConfig } = nextEnv
loadEnvConfig('.', process.env.NODE_ENV === 'development')