Fixed a bug where the map wasn't initialized before use
This commit is contained in:
parent
15f38a3f62
commit
37d977e444
@ -30,6 +30,8 @@ export class EndpointBrokerManagerFS {
|
|||||||
throw new Error("Broker already initialized")
|
throw new Error("Broker already initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EndpointBrokerManagerFS.endpoints = new Map()
|
||||||
|
|
||||||
const candidateConfigurations = (await listFiles(NGINX_TRACKED, true))
|
const candidateConfigurations = (await listFiles(NGINX_TRACKED, true))
|
||||||
const configurations: string[] = []
|
const configurations: string[] = []
|
||||||
|
|
||||||
@ -64,6 +66,11 @@ export class EndpointBrokerManagerFS {
|
|||||||
await file.release()
|
await file.release()
|
||||||
const endpoint = await parseConf(fsHeader, conf)
|
const endpoint = await parseConf(fsHeader, conf)
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Parsed Conf:\n${endpoint}`,
|
||||||
|
"Manager Init"
|
||||||
|
)
|
||||||
|
|
||||||
const relativePath = confPath.replace(NGINX_TRACKED, "")
|
const relativePath = confPath.replace(NGINX_TRACKED, "")
|
||||||
EndpointBrokerManagerFS.endpoints.set(
|
EndpointBrokerManagerFS.endpoints.set(
|
||||||
relativePath,
|
relativePath,
|
||||||
@ -291,13 +298,24 @@ export class EndpointBrokerManagerFS {
|
|||||||
|
|
||||||
const WATCHER = watch(NGINX_TRACK, OPTIONS, async (eventType, filename) => {
|
const WATCHER = watch(NGINX_TRACK, OPTIONS, async (eventType, filename) => {
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`EVENT: ${eventType}\nFile: ${filename}`,
|
||||||
|
"Watcher "
|
||||||
|
)
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const RELATIVE_PATH = filename
|
const RELATIVE_PATH = filename
|
||||||
const FULL_PATH = `${NGINX_TRACK}/${RELATIVE_PATH}`
|
const FULL_PATH = `${NGINX_TRACK}/${RELATIVE_PATH}`
|
||||||
|
|
||||||
|
if (!RELATIVE_PATH.endsWith(".conf")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: check if it's a directory, if so, skip
|
// TODO: check if it's a directory, if so, skip
|
||||||
|
|
||||||
@ -420,6 +438,11 @@ export class EndpointBrokerManagerFS {
|
|||||||
}
|
}
|
||||||
const endpoint = parseConf(fsHeader, conf)
|
const endpoint = parseConf(fsHeader, conf)
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Endpoint:\n${endpoint}`,
|
||||||
|
"Watcher Parsing"
|
||||||
|
)
|
||||||
|
|
||||||
EndpointBrokerManagerFS.endpoints.set(
|
EndpointBrokerManagerFS.endpoints.set(
|
||||||
RELATIVE_PATH,
|
RELATIVE_PATH,
|
||||||
endpoint
|
endpoint
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user