1
0
Fork 0
mirror of synced 2024-09-08 05:31:47 +12:00

Merge pull request #10487 from Budibase/fix/automation-log-issue

Potential fix for automation log issue
This commit is contained in:
Michael Drury 2023-05-05 11:59:25 +01:00 committed by GitHub
commit cfae0f6811
4 changed files with 14 additions and 10 deletions

View file

@ -40,6 +40,12 @@ function logging(queue: Queue, jobQueue: JobQueue) {
case JobQueue.APP_BACKUP: case JobQueue.APP_BACKUP:
eventType = "app-backup-event" eventType = "app-backup-event"
break break
case JobQueue.AUDIT_LOG:
eventType = "audit-log-event"
break
case JobQueue.SYSTEM_EVENT_QUEUE:
eventType = "system-event"
break
} }
if (process.env.NODE_DEBUG?.includes("bull")) { if (process.env.NODE_DEBUG?.includes("bull")) {
queue queue

View file

@ -34,8 +34,6 @@ function parseIntSafe(number?: string) {
} }
} }
let inThread = false
const environment = { const environment = {
// important - prefer app port to generic port // important - prefer app port to generic port
PORT: process.env.APP_PORT || process.env.PORT, PORT: process.env.APP_PORT || process.env.PORT,
@ -95,12 +93,8 @@ const environment = {
isProd: () => { isProd: () => {
return !isDev() return !isDev()
}, },
// used to check if already in a thread, don't thread further
setInThread: () => {
inThread = true
},
isInThread: () => { isInThread: () => {
return inThread return process.env.FORKED_PROCESS
}, },
} }

View file

@ -39,6 +39,12 @@ export class Thread {
const workerOpts: any = { const workerOpts: any = {
autoStart: true, autoStart: true,
maxConcurrentWorkers: this.count, maxConcurrentWorkers: this.count,
workerOptions: {
env: {
...process.env,
FORKED_PROCESS: "1",
},
},
} }
if (opts.timeoutMs) { if (opts.timeoutMs) {
this.timeoutMs = opts.timeoutMs this.timeoutMs = opts.timeoutMs

View file

@ -25,11 +25,9 @@ function makeVariableKey(queryId: string, variable: string) {
export function threadSetup() { export function threadSetup() {
// don't run this if not threading // don't run this if not threading
if (env.isTest() || env.DISABLE_THREADING) { if (env.isTest() || env.DISABLE_THREADING || !env.isInThread()) {
return return
} }
// when thread starts, make sure it is recorded
env.setInThread()
db.init() db.init()
} }