fix(config): Subscribe to config changes instead of piggy backing off the loader watch.

Signed-off-by: Harry Hogg <hhogg@spotify.com>
This commit is contained in:
Harry Hogg
2021-09-30 13:32:03 +01:00
parent 12428bf338
commit 18d14d655e
3 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -191,13 +191,12 @@ export async function loadBackendConfig(options: {
configRoot: paths.targetRoot,
configPaths: configPaths.map(opt => resolvePath(opt)),
watch: {
async onChange(newConfigs) {
onChange(newConfigs) {
options.logger.info(
`Reloaded config from ${newConfigs.map(c => c.context).join(', ')}`,
);
config.setConfig(ConfigReader.fromConfigs(newConfigs));
await updateRedactionMap(configs, options.logger);
},
stopSignal: new Promise(resolve => {
if (currentCancelFunc) {
@@ -218,7 +217,10 @@ export async function loadBackendConfig(options: {
);
config.setConfig(ConfigReader.fromConfigs(configs));
await updateRedactionMap(configs, options.logger);
// Subscribe to config changes and update the redaction list for logging
updateRedactionMap(schema, configs, options.logger);
config.subscribe(() => updateRedactionMap(schema, configs, options.logger));
return config;
}
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { merge } from 'lodash';
import * as winston from 'winston';
import { LoggerOptions } from 'winston';
-1
View File
@@ -86,7 +86,6 @@ async function main() {
argv: process.argv,
logger,
});
const createEnv = makeCreateEnv(config);
const healthcheckEnv = useHotMemoize(module, () => createEnv('healthcheck'));