From 0f524814647c98837382fe995f162b7b06173be4 Mon Sep 17 00:00:00 2001 From: PauI Ostrovckij Date: Tue, 30 Sep 2025 10:25:26 +0300 Subject: [PATCH 1/3] [feature] Change logger level in Admin Panel --- Common/config/default.json | 1 + Common/config/log4js/development.json | 2 +- Common/config/log4js/production.json | 2 +- Common/config/schemas/config.schema.json | 12 ++++++++++++ Common/sources/logger.js | 18 +++++++++++++++++- Common/sources/runtimeConfigManager.js | 8 ++++++++ 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Common/config/default.json b/Common/config/default.json index 18f10551..22d4db2b 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -21,6 +21,7 @@ }, "log": { "filePath": "", + "level": "WARN", "options": { "replaceConsole": true } diff --git a/Common/config/log4js/development.json b/Common/config/log4js/development.json index ff1d0326..ba2748e9 100644 --- a/Common/config/log4js/development.json +++ b/Common/config/log4js/development.json @@ -9,6 +9,6 @@ } }, "categories": { - "default": {"appenders": ["default"], "level": "ALL"} + "default": {"appenders": ["default"]} } } diff --git a/Common/config/log4js/production.json b/Common/config/log4js/production.json index 5b6673e9..df2a60bc 100644 --- a/Common/config/log4js/production.json +++ b/Common/config/log4js/production.json @@ -9,6 +9,6 @@ } }, "categories": { - "default": {"appenders": ["default"], "level": "WARN"} + "default": {"appenders": ["default"]} } } diff --git a/Common/config/schemas/config.schema.json b/Common/config/schemas/config.schema.json index e14a2581..c748899f 100644 --- a/Common/config/schemas/config.schema.json +++ b/Common/config/schemas/config.schema.json @@ -214,6 +214,18 @@ } } } + }, + "log": { + "type": "object", + "additionalProperties": true, + "x-scope": "admin", + "properties": { + "level": { + "type": "string", + "enum": ["ALL", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF"], + "description": "Logging level for the application" + } + } } } } diff --git a/Common/sources/logger.js b/Common/sources/logger.js index 0aa6066d..71ee37bd 100644 --- a/Common/sources/logger.js +++ b/Common/sources/logger.js @@ -34,9 +34,14 @@ const config = require('config'); const util = require('util'); +const path = require('path'); +const fs = require('fs'); const log4js = require('log4js'); const layouts = require('log4js/lib/layouts'); +const logConfigPath = config.get('log.filePath'); +let logLevel = config.get('log.level'); +const fullLogConfigPath = path.resolve(__dirname, '..', logConfigPath); // https://stackoverflow.com/a/36643588 const dateToJSONWithTZ = function (d) { @@ -78,7 +83,18 @@ log4js.addLayout('patternWithTokens', cfg => { return layouts.patternLayout(pattern, tokens); }); -log4js.configure(config.get('log.filePath')); +exports.configureLogger = function (level = logLevel) { + const logConfig = JSON.parse(fs.readFileSync(fullLogConfigPath, 'utf8')); + Object.keys(logConfig.categories).forEach(categoryName => { + logConfig.categories[categoryName].level = level; + }); + logLevel = level; + log4js.configure(logConfig); +}; +exports.configureLogger(); +exports.getLogLevel = function () { + return logLevel; +}; const logger = log4js.getLogger('nodeJS'); diff --git a/Common/sources/runtimeConfigManager.js b/Common/sources/runtimeConfigManager.js index 3fbab251..07953b61 100644 --- a/Common/sources/runtimeConfigManager.js +++ b/Common/sources/runtimeConfigManager.js @@ -38,6 +38,7 @@ const config = require('config'); const NodeCache = require('node-cache'); const operationContext = require('./operationContext'); const utils = require('./utils'); +const logger = require('./logger'); const cfgRuntimeConfig = config.get('runtimeConfig'); const configFilePath = cfgRuntimeConfig.filePath; @@ -102,6 +103,7 @@ async function saveConfig(ctx, config) { */ function handleConfigFileChange(eventTypeOrCurrent, filenameOrPrevious) { try { + const logLevel = logger.getLogLevel(); let shouldReload = false; if (typeof eventTypeOrCurrent === 'object' && eventTypeOrCurrent.isFile) { @@ -113,6 +115,12 @@ function handleConfigFileChange(eventTypeOrCurrent, filenameOrPrevious) { } if (shouldReload) { nodeCache.del(configFileName); + // Reload config and update logging level + getConfig(operationContext.global).then(config => { + if (config.log.level !== logLevel) { + logger.configureLogger(config.log.level); + } + }); } } catch (err) { operationContext.global.logger.error(`handleConfigFileChange error: ${err.message}`); From 81fef452baba721ebd8bc87d5f2e331d84ba826f Mon Sep 17 00:00:00 2001 From: PauI Ostrovckij Date: Tue, 30 Sep 2025 10:27:28 +0300 Subject: [PATCH 2/3] [refactor] Remove unused code --- DocService/npm-shrinkwrap.json | 16 -- DocService/package.json | 1 - .../sources/routes/adminpanel/router.js | 154 ------------------ DocService/sources/routes/config.js | 92 ----------- DocService/sources/server.js | 11 -- 5 files changed, 274 deletions(-) delete mode 100644 DocService/sources/routes/adminpanel/router.js delete mode 100644 DocService/sources/routes/config.js diff --git a/DocService/npm-shrinkwrap.json b/DocService/npm-shrinkwrap.json index 4c369851..14b95ebe 100644 --- a/DocService/npm-shrinkwrap.json +++ b/DocService/npm-shrinkwrap.json @@ -713,22 +713,6 @@ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==" }, - "cookie-parser": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", - "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", - "requires": { - "cookie": "0.7.2", - "cookie-signature": "1.0.6" - }, - "dependencies": { - "cookie": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==" - } - } - }, "cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", diff --git a/DocService/package.json b/DocService/package.json index 6a99873f..65defc76 100644 --- a/DocService/package.json +++ b/DocService/package.json @@ -16,7 +16,6 @@ "bytes": "3.1.2", "co": "4.6.0", "config": "3.3.12", - "cookie-parser": "^1.4.7", "cors": "^2.8.5", "cron": "1.5.0", "dmdb": "1.0.36002", diff --git a/DocService/sources/routes/adminpanel/router.js b/DocService/sources/routes/adminpanel/router.js deleted file mode 100644 index f3b5a53c..00000000 --- a/DocService/sources/routes/adminpanel/router.js +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2024 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -'use strict'; -const config = require('config'); -const express = require('express'); -const operationContext = require('../../../../Common/sources/operationContext'); -const tenantBaseDir = config.get('tenants.baseDir'); -// const isMultitenantMode = config.get('tenants.isMultitenantMode'); -const defaultTenantSecret = config.get('services.CoAuthoring.secret.browser.string'); -const filenameSecret = config.get('tenants.filenameSecret'); -const jwt = require('jsonwebtoken'); -const fs = require('fs'); -const path = require('path'); -const cookieParser = require('cookie-parser'); - -const router = express.Router(); - -// Middleware to parse JSON request bodies -router.use(express.json()); - -// Middleware to parse cookies -router.use(cookieParser()); - -router.get('/me', async (req, res) => { - try { - const token = req.cookies.accessToken; - if (!token) { - return res.status(401).json({error: 'Unauthorized'}); - } - - // Try to verify with default tenant secret first - try { - const decoded = jwt.verify(token, defaultTenantSecret); - res.json(decoded); - } catch { - // If default secret fails, try to find the tenant and verify with their secret - const tenantList = fs.readdirSync(tenantBaseDir); - for (const tenant of tenantList) { - try { - const tenantSecret = fs.readFileSync(path.join(tenantBaseDir, tenant, filenameSecret), 'utf8'); - const decoded = jwt.verify(token, tenantSecret); - res.json({ - tenant: decoded.tenant, - isAdmin: decoded.isAdmin - }); - return; - } catch { - // Continue to next tenant - continue; - } - } - // If no tenant secret works, return unauthorized - return res.status(401).json({error: 'Invalid token'}); - } - } catch (error) { - console.log('error', error); - res.status(401).json({error: 'Unauthorized'}); - } -}); - -router.post('/login', async (req, res) => { - const ctx = new operationContext.Context(); - ctx.initDefault(); - try { - const {secret} = req.body; - const tenant = findTenantBySecret(secret); - if (!tenant) { - return res.status(401).json({error: 'Invalid secret'}); - } - const token = jwt.sign({...tenant}, secret, {expiresIn: '1h'}); - - res.cookie('accessToken', token, { - httpOnly: true, - sameSite: 'strict', - maxAge: 60 * 60 * 1000, - path: '/' - }); - - res.json({tenant: tenant.tenant, isAdmin: tenant.isAdmin}); - } catch (error) { - ctx.logger.error('Config get error: %s', error.stack); - res.status(500).json({error: 'Internal server error'}); - } -}); - -router.post('/logout', async (req, res) => { - try { - // Clear the httpOnly accessToken cookie - res.clearCookie('accessToken', { - httpOnly: true, - sameSite: 'strict', - path: '/' - }); - - res.json({message: 'Logged out successfully'}); - } catch (error) { - console.log('logout error', error); - res.status(500).json({error: 'Internal server error'}); - } -}); - -//TODO: make function async, use cache -function findTenantBySecret(secret) { - if (secret === defaultTenantSecret) { - return { - tenant: config.get('tenants.defaultTenant'), - isAdmin: true - }; - } - - const tenantList = fs.readdirSync(tenantBaseDir); - for (const tenant of tenantList) { - const tenantSecret = fs.readFileSync(path.join(tenantBaseDir, tenant, filenameSecret), 'utf8'); - if (tenantSecret === secret) { - return { - tenant, - isAdmin: true - }; - } - } - return null; -} - -module.exports = router; diff --git a/DocService/sources/routes/config.js b/DocService/sources/routes/config.js deleted file mode 100644 index deea9ff9..00000000 --- a/DocService/sources/routes/config.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2024 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -const config = require('config'); -const express = require('express'); -const bodyParser = require('body-parser'); -const tenantManager = require('../../../Common/sources/tenantManager'); -const operationContext = require('../../../Common/sources/operationContext'); -const runtimeConfigManager = require('../../../Common/sources/runtimeConfigManager'); - -const router = express.Router(); - -const rawFileParser = bodyParser.raw({ - inflate: true, - limit: config.get('services.CoAuthoring.server.limits_tempfile_upload'), - type() { - return true; - } -}); - -router.get('/', async (req, res) => { - const ctx = new operationContext.Context(); - let result = '{}'; - try { - ctx.initFromRequest(req); - await ctx.initTenantCache(); - ctx.logger.debug('config get start'); - const cfg = ctx.getFullCfg(); - result = JSON.stringify(cfg); - } catch (error) { - ctx.logger.error('config get error: %s', error.stack); - } finally { - res.setHeader('Content-Type', 'application/json'); - res.send(result); - ctx.logger.debug('config end'); - } -}); - -router.post('/', rawFileParser, async (req, res) => { - const ctx = new operationContext.Context(); - try { - ctx.initFromRequest(req); - await ctx.initTenantCache(); - - const newConfig = JSON.parse(req.body); - - if (tenantManager.isMultitenantMode(ctx) && !tenantManager.isDefaultTenant(ctx)) { - await tenantManager.setTenantConfig(ctx, newConfig); - } else { - await runtimeConfigManager.saveConfig(ctx, newConfig); - } - - res.sendStatus(200); - } catch (error) { - ctx.logger.error('Configuration save error: %s', error.stack); - res.status(500).json({ - error: 'Failed to save configuration', - details: error.message - }); - } -}); - -module.exports = router; diff --git a/DocService/sources/server.js b/DocService/sources/server.js index 5c55ddb8..0c012fed 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -57,12 +57,9 @@ const commonDefines = require('./../../Common/sources/commondefines'); const operationContext = require('./../../Common/sources/operationContext'); const tenantManager = require('./../../Common/sources/tenantManager'); const staticRouter = require('./routes/static'); -const configRouter = require('./routes/config'); -const adminpanelRouter = require('./routes/adminpanel/router'); const infoRouter = require('./routes/info'); const ms = require('ms'); const aiProxyHandler = require('./ai/aiProxyHandler'); -const cors = require('cors'); const cfgWopiEnable = config.get('wopi.enable'); const cfgWopiDummyEnable = config.get('wopi.dummy.enable'); @@ -118,12 +115,6 @@ const updateLicense = async () => { operationContext.global.logger.error('updateLicense error: %s', err.stack); } }; -const corsWithCredentials = cors({ - origin: true, - credentials: true, - methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], - allowedHeaders: ['Content-Type', 'Authorization'] -}); operationContext.global.logger.warn('Express server starting...'); @@ -302,8 +293,6 @@ docsCoServer.install(server, app, () => { app.post('/docbuilder', utils.checkClientIp, rawFileParser, (req, res) => { converterService.builder(req, res); }); - app.use('/info/config', corsWithCredentials, utils.checkClientIp, configRouter); - app.use('/info/adminpanel', corsWithCredentials, utils.checkClientIp, adminpanelRouter); app.get('/info/plugin/settings', utils.checkClientIp, aiProxyHandler.requestSettings); app.post('/info/plugin/models', utils.checkClientIp, rawFileParser, aiProxyHandler.requestModels); // Shared Info router (provides /info.json) From 14db0091c58df207c7434083236cd69a18b26bec Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 1 Oct 2025 02:28:27 +0300 Subject: [PATCH 3/3] [feature] Refactor configureLogger --- Common/config/default.json | 1 - Common/config/log4js/development.json | 2 +- Common/config/log4js/production.json | 2 +- Common/config/schemas/config.schema.json | 26 +++++++++++++++++---- Common/sources/logger.js | 29 ++++++++++++------------ Common/sources/runtimeConfigManager.js | 5 +--- DocService/sources/DocsCoServer.js | 5 ---- DocService/sources/server.js | 5 ++++ FileConverter/sources/convertermaster.js | 5 ++++ 9 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Common/config/default.json b/Common/config/default.json index 22d4db2b..18f10551 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -21,7 +21,6 @@ }, "log": { "filePath": "", - "level": "WARN", "options": { "replaceConsole": true } diff --git a/Common/config/log4js/development.json b/Common/config/log4js/development.json index ba2748e9..ff1d0326 100644 --- a/Common/config/log4js/development.json +++ b/Common/config/log4js/development.json @@ -9,6 +9,6 @@ } }, "categories": { - "default": {"appenders": ["default"]} + "default": {"appenders": ["default"], "level": "ALL"} } } diff --git a/Common/config/log4js/production.json b/Common/config/log4js/production.json index df2a60bc..5b6673e9 100644 --- a/Common/config/log4js/production.json +++ b/Common/config/log4js/production.json @@ -9,6 +9,6 @@ } }, "categories": { - "default": {"appenders": ["default"]} + "default": {"appenders": ["default"], "level": "WARN"} } } diff --git a/Common/config/schemas/config.schema.json b/Common/config/schemas/config.schema.json index c748899f..5c7c7879 100644 --- a/Common/config/schemas/config.schema.json +++ b/Common/config/schemas/config.schema.json @@ -220,10 +220,28 @@ "additionalProperties": true, "x-scope": "admin", "properties": { - "level": { - "type": "string", - "enum": ["ALL", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF"], - "description": "Logging level for the application" + "options": { + "type": "object", + "additionalProperties": true, + "properties": { + "categories": { + "type": "object", + "additionalProperties": true, + "properties": { + "default": { + "type": "object", + "additionalProperties": true, + "properties": { + "level": { + "type": "string", + "enum": ["ALL", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF"], + "description": "Logging level for the application" + } + } + } + } + } + } } } } diff --git a/Common/sources/logger.js b/Common/sources/logger.js index 71ee37bd..d933e6ba 100644 --- a/Common/sources/logger.js +++ b/Common/sources/logger.js @@ -34,14 +34,12 @@ const config = require('config'); const util = require('util'); -const path = require('path'); const fs = require('fs'); const log4js = require('log4js'); const layouts = require('log4js/lib/layouts'); const logConfigPath = config.get('log.filePath'); -let logLevel = config.get('log.level'); -const fullLogConfigPath = path.resolve(__dirname, '..', logConfigPath); +const logOptions = config.get('log.options'); // https://stackoverflow.com/a/36643588 const dateToJSONWithTZ = function (d) { @@ -83,18 +81,15 @@ log4js.addLayout('patternWithTokens', cfg => { return layouts.patternLayout(pattern, tokens); }); -exports.configureLogger = function (level = logLevel) { - const logConfig = JSON.parse(fs.readFileSync(fullLogConfigPath, 'utf8')); - Object.keys(logConfig.categories).forEach(categoryName => { - logConfig.categories[categoryName].level = level; - }); - logLevel = level; - log4js.configure(logConfig); -}; -exports.configureLogger(); -exports.getLogLevel = function () { - return logLevel; -}; +const cachedLogConfig = JSON.parse(fs.readFileSync(logConfigPath, 'utf8')); +let curLogConfig = cachedLogConfig; + +function configureLogger(options) { + const mergedOptions = config.util.extendDeep({}, cachedLogConfig, options); + log4js.configure(mergedOptions); + curLogConfig = mergedOptions; +} +configureLogger(logOptions); const logger = log4js.getLogger('nodeJS'); @@ -129,3 +124,7 @@ exports.fatal = function () { exports.shutdown = function (callback) { return log4js.shutdown(callback); }; +exports.configureLogger = configureLogger; +exports.getLoggerConfig = function () { + return curLogConfig; +}; diff --git a/Common/sources/runtimeConfigManager.js b/Common/sources/runtimeConfigManager.js index 07953b61..5a288b53 100644 --- a/Common/sources/runtimeConfigManager.js +++ b/Common/sources/runtimeConfigManager.js @@ -103,7 +103,6 @@ async function saveConfig(ctx, config) { */ function handleConfigFileChange(eventTypeOrCurrent, filenameOrPrevious) { try { - const logLevel = logger.getLogLevel(); let shouldReload = false; if (typeof eventTypeOrCurrent === 'object' && eventTypeOrCurrent.isFile) { @@ -117,9 +116,7 @@ function handleConfigFileChange(eventTypeOrCurrent, filenameOrPrevious) { nodeCache.del(configFileName); // Reload config and update logging level getConfig(operationContext.global).then(config => { - if (config.log.level !== logLevel) { - logger.configureLogger(config.log.level); - } + logger.configureLogger(config?.log?.options); }); } } catch (err) { diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index cd30d18e..9269e001 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -99,7 +99,6 @@ const pubsubService = require('./pubsubRabbitMQ'); const wopiClient = require('./wopiClient'); const queueService = require('./../../Common/sources/taskqueueRabbitMQ'); const operationContext = require('./../../Common/sources/operationContext'); -const runtimeConfigManager = require('./../../Common/sources/runtimeConfigManager'); const tenantManager = require('./../../Common/sources/tenantManager'); const {notificationTypes, ...notificationService} = require('../../Common/sources/notificationService'); const aiProxyHandler = require('./ai/aiProxyHandler'); @@ -4348,10 +4347,6 @@ exports.install = function (server, app, callbackFunction) { }); }); - //Initialize watch here to avoid circular import with operationContext - runtimeConfigManager.initRuntimeConfigWatcher(operationContext.global).catch(err => { - operationContext.global.logger.warn('initRuntimeConfigWatcher error: %s', err.stack); - }); void aiProxyHandler.getPluginSettings(operationContext.global); }; exports.setLicenseInfo = async function (globalCtx, data, original) { diff --git a/DocService/sources/server.js b/DocService/sources/server.js index 0c012fed..8d2ac28a 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -60,6 +60,7 @@ const staticRouter = require('./routes/static'); const infoRouter = require('./routes/info'); const ms = require('ms'); const aiProxyHandler = require('./ai/aiProxyHandler'); +const runtimeConfigManager = require('./../../Common/sources/runtimeConfigManager'); const cfgWopiEnable = config.get('wopi.enable'); const cfgWopiDummyEnable = config.get('wopi.dummy.enable'); @@ -499,5 +500,9 @@ process.on('uncaughtException', err => { }); }); +//Initialize watch here to avoid circular import with operationContext +runtimeConfigManager.initRuntimeConfigWatcher(operationContext.global).catch(err => { + operationContext.global.logger.warn('initRuntimeConfigWatcher error: %s', err.stack); +}); //after all required modules in all files moduleReloader.finalizeConfigWithRuntime(); diff --git a/FileConverter/sources/convertermaster.js b/FileConverter/sources/convertermaster.js index 62571f32..a7d1927a 100644 --- a/FileConverter/sources/convertermaster.js +++ b/FileConverter/sources/convertermaster.js @@ -37,6 +37,7 @@ const moduleReloader = require('./../../Common/sources/moduleReloader'); const config = moduleReloader.requireConfigWithRuntime(); const logger = require('./../../Common/sources/logger'); const operationContext = require('./../../Common/sources/operationContext'); +const runtimeConfigManager = require('./../../Common/sources/runtimeConfigManager'); if (cluster.isMaster) { const fs = require('fs'); @@ -95,6 +96,10 @@ if (cluster.isMaster) { } else { const converter = require('./converter'); converter.run(); + //Initialize watch here to avoid circular import with operationContext + runtimeConfigManager.initRuntimeConfigWatcher(operationContext.global).catch(err => { + operationContext.global.logger.warn('initRuntimeConfigWatcher error: %s', err.stack); + }); } process.on('uncaughtException', err => {