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:
@@ -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';
|
||||
|
||||
@@ -86,7 +86,6 @@ async function main() {
|
||||
argv: process.argv,
|
||||
logger,
|
||||
});
|
||||
|
||||
const createEnv = makeCreateEnv(config);
|
||||
|
||||
const healthcheckEnv = useHotMemoize(module, () => createEnv('healthcheck'));
|
||||
|
||||
Reference in New Issue
Block a user