diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4168df..bfc83c59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,3 +2,9 @@ ## develop ### Back-end * + +## 5.1.1 +### Back-end +* Add reconnection.attempts, reconnection.delay options to config - applicable for editor-server connection +* Add sockjs config section for testing purposes +* Fix inconsistent database status after files assemble in case of rapid open/close connection diff --git a/Common/config/default.json b/Common/config/default.json index f5c1100d..cfedb7e2 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -51,11 +51,9 @@ "port": 8000, "workerpercpu": 1, "mode": "development", - "sockjsUrl": "", "limits_tempfile_upload": 104857600, "limits_image_size": 26214400, "limits_image_download_timeout": 120, - "editor_settings_spellchecker_url": "/spellchecker", "callbackRequestTimeout": 120, "healthcheckfilepath": "../public/healthcheck.docx", "savetimeoutdelay": 5000, @@ -168,6 +166,17 @@ "plugins": { "uri": "/sdkjs-plugins", "autostart": [] + }, + "editor":{ + "spellcheckerUrl": "/spellchecker", + "reconnection":{ + "attempts": 50, + "delay": "2s" + } + }, + "sockjs": { + "sockjs_url": "", + "websocket": true } } }, diff --git a/Common/config/development-mac.json b/Common/config/development-mac.json index 2c008a22..d967cf01 100644 --- a/Common/config/development-mac.json +++ b/Common/config/development-mac.json @@ -11,9 +11,10 @@ "CoAuthoring": { "server": { "port": 8080, - "sockjsUrl": "/office/vendor/sockjs/sockjs.min.js", - "editor_settings_spellchecker_url": "", "static_content": { + "/fonts": { + "path": "../../../fonts" + }, "/sdkjs": { "path": "../../../sdkjs" }, @@ -36,6 +37,12 @@ "dbPort": 3306, "dbUser": "root", "dbPass": "onlyoffice" + }, + "editor": { + "spellcheckerUrl": "" + }, + "sockjs": { + "sockjs_url": "/office/vendor/sockjs/sockjs.min.js" } } }, diff --git a/Common/config/development-windows.json b/Common/config/development-windows.json index 10da22aa..0733cb5d 100644 --- a/Common/config/development-windows.json +++ b/Common/config/development-windows.json @@ -11,9 +11,10 @@ "CoAuthoring": { "server": { "port": 8001, - "sockjsUrl": "/web-apps/vendor/sockjs/sockjs.min.js", - "editor_settings_spellchecker_url": "http://127.0.0.1:8080", "static_content": { + "/fonts": { + "path": "../../../fonts" + }, "/sdkjs": { "path": "../../../sdkjs" }, @@ -25,9 +26,6 @@ }, "/sdkjs-plugins": { "path": "../../../sdkjs-plugins" - }, - "/fonts": { - "path": "../../../fonts" } } }, @@ -39,6 +37,12 @@ "dbPort": 3306, "dbUser": "root", "dbPass": "onlyoffice" + }, + "editor": { + "spellcheckerUrl": "http://127.0.0.1:8080" + }, + "sockjs": { + "sockjs_url": "/web-apps/vendor/sockjs/sockjs.min.js" } } }, diff --git a/Common/config/production-linux.json b/Common/config/production-linux.json index f80b038f..1b083c61 100644 --- a/Common/config/production-linux.json +++ b/Common/config/production-linux.json @@ -10,8 +10,11 @@ "services": { "CoAuthoring": { "server": { - "sockjsUrl": "/web-apps/vendor/sockjs/sockjs.min.js", "static_content": { + "/fonts": { + "path": "/var/www/onlyoffice/documentserver/fonts", + "options": {"maxAge": "7d"} + }, "/sdkjs": { "path": "/var/www/onlyoffice/documentserver/sdkjs", "options": {"maxAge": "7d"} @@ -32,6 +35,9 @@ }, "utils": { "utils_common_fontdir": "/usr/share/fonts" + }, + "sockjs": { + "sockjs_url": "/web-apps/vendor/sockjs/sockjs.min.js" } } }, diff --git a/Common/config/production-windows.json b/Common/config/production-windows.json index 07cfaa34..b581531e 100644 --- a/Common/config/production-windows.json +++ b/Common/config/production-windows.json @@ -10,8 +10,11 @@ "services": { "CoAuthoring": { "server": { - "sockjsUrl": "/web-apps/vendor/sockjs/sockjs.min.js", "static_content": { + "/fonts": { + "path": "../../../fonts", + "options": {"maxAge": "7d"} + }, "/sdkjs": { "path": "../../../sdkjs", "options": {"maxAge": "7d"} @@ -32,6 +35,9 @@ }, "utils": { "utils_common_fontdir": "C:\\Windows\\Fonts" + }, + "sockjs": { + "sockjs_url": "/web-apps/vendor/sockjs/sockjs.min.js" } } }, diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index d32be99f..ad3ac5e6 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -100,7 +100,8 @@ const pubsubRedis = require('./pubsubRedis'); const pubsubService = require('./' + config.get('pubsub.name')); const queueService = require('./../../Common/sources/taskqueueRabbitMQ'); const rabbitMQCore = require('./../../Common/sources/rabbitMQCore'); -const cfgSpellcheckerUrl = config.get('server.editor_settings_spellchecker_url'); +let cfgEditor = JSON.parse(JSON.stringify(config.get('editor'))); +cfgEditor['reconnection']['delay'] = ms(cfgEditor['reconnection']['delay']); const cfgCallbackRequestTimeout = config.get('server.callbackRequestTimeout'); //The waiting time to document assembly when all out(not 0 in case of F5 in the browser) const cfgAscSaveTimeOutDelay = config.get('server.savetimeoutdelay'); @@ -122,7 +123,7 @@ const cfgExpSessionIdle = ms(config.get('expire.sessionidle')); const cfgExpSessionAbsolute = ms(config.get('expire.sessionabsolute')); const cfgExpSessionCloseCommand = ms(config.get('expire.sessionclosecommand')); const cfgExpUpdateVersionStatus = ms(config.get('expire.updateVersionStatus')); -const cfgSockjsUrl = config.get('server.sockjsUrl'); +const cfgSockjs = config.get('sockjs'); const cfgTokenEnableBrowser = config.get('token.enable.browser'); const cfgTokenEnableRequestInbox = config.get('token.enable.request.inbox'); const cfgTokenEnableRequestOutbox = config.get('token.enable.request.outbox'); @@ -1148,8 +1149,7 @@ exports.getRequestParams = getRequestParams; exports.checkJwtHeader = checkJwtHeader; exports.checkJwtPayloadHash = checkJwtPayloadHash; exports.install = function(server, callbackFunction) { - var sockjs_opts = {sockjs_url: cfgSockjsUrl}, - sockjs_echo = sockjs.createServer(sockjs_opts), + var sockjs_echo = sockjs.createServer(cfgSockjs), urlParse = new RegExp("^/doc/([" + constants.DOC_ID_PATTERN + "]*)/c.+", 'i'); sockjs_echo.on('connection', function(conn) { @@ -2217,10 +2217,11 @@ exports.install = function(server, callbackFunction) { indexUser: conn.user.indexUser, hasForgotten: opt_hasForgotten, jwt: (!bIsRestore && cfgTokenEnableBrowser) ? fillJwtByConnection(conn) : undefined, - g_cAscSpellCheckUrl: cfgSpellcheckerUrl, + g_cAscSpellCheckUrl: cfgEditor["spellcheckerUrl"], buildVersion: commonDefines.buildVersion, buildNumber: commonDefines.buildNumber, - licenseType: conn.licenseType + licenseType: conn.licenseType, + settings: cfgEditor }; sendData(conn, sendObject);//Or 0 if fails } diff --git a/DocService/sources/canvasservice.js b/DocService/sources/canvasservice.js index 42b4c286..a338215d 100644 --- a/DocService/sources/canvasservice.js +++ b/DocService/sources/canvasservice.js @@ -638,6 +638,14 @@ function* commandSfcCallback(cmd, isSfcm) { statusOk = docsCoServer.c_oAscServerStatus.MustSave; statusErr = docsCoServer.c_oAscServerStatus.Corrupted; } + let updateMask = new taskResult.TaskResultData(); + updateMask.key = docId; + updateMask.status = taskResult.FileStatus.SaveVersion; + updateMask.statusInfo = cmd.getData(); + let updateIfTask = new taskResult.TaskResultData(); + updateIfTask.status = taskResult.FileStatus.UpdateVersion; + updateIfTask.statusInfo = Math.floor(Date.now() / 60000);//minutes + let updateIfRes; if (getRes) { logger.debug('Callback commandSfcCallback: docId = %s callback = %s', docId, getRes.server.href); var outputSfc = new commonDefines.OutputSfcData(); @@ -727,15 +735,10 @@ function* commandSfcCallback(cmd, isSfcm) { var lastSaveDate = lastSave ? new Date(lastSave.time) : new Date(); outputSfc.setLastSave(lastSaveDate.toISOString()); outputSfc.setNotModified(notModified); - var updateMask = new taskResult.TaskResultData(); - updateMask.key = docId; - updateMask.status = taskResult.FileStatus.SaveVersion; - updateMask.statusInfo = cmd.getData(); - var updateIfTask = new taskResult.TaskResultData(); - updateIfTask.status = taskResult.FileStatus.UpdateVersion; - updateIfTask.statusInfo = Math.floor(Date.now() / 60000);//minutes - var updateIfRes = yield taskResult.updateIf(updateIfTask, updateMask); + updateIfRes = yield taskResult.updateIf(updateIfTask, updateMask); if (updateIfRes.affectedRows > 0) { + updateMask.status = updateIfTask.status; + updateMask.statusInfo = updateIfTask.statusInfo; var replyStr = null; try { replyStr = yield* docsCoServer.sendServerRequest(docId, uri, outputSfc, checkAuthorizationLength); @@ -756,19 +759,17 @@ function* commandSfcCallback(cmd, isSfcm) { requestRes = (null == savedVal || '1' === savedVal); } if (requestRes) { + updateIfTask = undefined; yield docsCoServer.cleanDocumentOnExitPromise(docId, true); if (isOpenFromForgotten) { //remove forgotten file in cache yield cleanupCache(docId); } } else { - var updateTask = new taskResult.TaskResultData(); - updateTask.key = docId; - updateTask.status = taskResult.FileStatus.Ok; - updateTask.statusInfo = constants.NO_ERROR; - yield taskResult.update(updateTask); storeForgotten = true; } + } else { + updateIfTask = undefined; } } } @@ -776,6 +777,15 @@ function* commandSfcCallback(cmd, isSfcm) { logger.warn('Empty Callback commandSfcCallback: docId = %s', docId); storeForgotten = true; } + if (undefined !== updateIfTask && !isSfcm) { + logger.debug('commandSfcCallback restore FileStatus.Ok status: docId = %s', docId); + updateIfTask.status = taskResult.FileStatus.Ok; + updateIfTask.statusInfo = constants.NO_ERROR; + updateIfRes = yield taskResult.updateIf(updateIfTask, updateMask); + if (!(updateIfRes.affectedRows > 0)) { + logger.debug('commandSfcCallback restore FileStatus.Ok status failed: docId = %s', docId); + } + } if (storeForgotten && (!isError || isErrorCorrupted)) { try { logger.debug("storeForgotten: docId = %s", docId); diff --git a/Makefile b/Makefile index 17e57899..a0626854 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ GRUNT_FILES = Gruntfile.js.out PRODUCT_VERSION ?= 0.0.0 BUILD_NUMBER ?= 0 +DOCUMENT_ROOT ?= /var/www/onlyoffice/documentserver + ifeq ($(OS),Windows_NT) PLATFORM := win EXEC_EXT := .exe @@ -146,6 +148,7 @@ install: sudo adduser --quiet --home /var/www/onlyoffice --system --group onlyoffice sudo mkdir -p /var/www/onlyoffice/documentserver + sudo mkdir -p /var/www/onlyoffice/documentserver/fonts sudo mkdir -p /var/log/onlyoffice/documentserver sudo mkdir -p /var/lib/onlyoffice/documentserver/App_Data @@ -168,11 +171,15 @@ install: sudo ln -s /var/www/onlyoffice/documentserver/server/FileConverter/bin/libicudata.so.55 /lib/libicudata.so.55 sudo ln -s /var/www/onlyoffice/documentserver/server/FileConverter/bin/libicuuc.so.55 /lib/libicuuc.so.55 - sudo -u onlyoffice "/var/www/onlyoffice/documentserver/server/tools/AllFontsGen"\ - "/usr/share/fonts"\ - "/var/www/onlyoffice/documentserver/sdkjs/common/AllFonts.js"\ - "/var/www/onlyoffice/documentserver/sdkjs/common/Images"\ - "/var/www/onlyoffice/documentserver/server/FileConverter/bin/font_selection.bin" + sudo -u onlyoffice "${DOCUMENT_ROOT}/server/tools/AllFontsGen"\ + --input="${DOCUMENT_ROOT}/core-fonts"\ + --allfonts-web="${DOCUMENT_ROOT}/sdkjs/common/AllFonts.js"\ + --allfonts="${DOCUMENT_ROOT}/server/FileConverter/bin/AllFonts.js"\ + --images="${DOCUMENT_ROOT}/sdkjs/common/Images"\ + --selection="${DOCUMENT_ROOT}/server/FileConverter/bin/font_selection.bin"\ + --output-web="${DOCUMENT_ROOT}/fonts"\ + --use-system="true" + uninstall: sudo userdel onlyoffice diff --git a/SpellChecker/sources/spellCheck.js b/SpellChecker/sources/spellCheck.js index 30c3ad16..f1486a10 100644 --- a/SpellChecker/sources/spellCheck.js +++ b/SpellChecker/sources/spellCheck.js @@ -38,7 +38,7 @@ const logger = require('./../../Common/sources/logger'); const utils = require('./../../Common/sources/utils'); const fs = require('fs'); const co = require('co'); -const cfgSockjsUrl = require('config').get('services.CoAuthoring.server.sockjsUrl'); +const cfgSockjs = require('config').get('services.CoAuthoring.sockjs'); const languages = require('./languages'); const allLanguages = languages.allLanguages; const path = require('path'); @@ -92,8 +92,7 @@ exports.install = function (server, callbackFunction) { }); }); - const sockjs_opts = {sockjs_url: cfgSockjsUrl}; - const sockjs_echo = sockjs.createServer(sockjs_opts); + const sockjs_echo = sockjs.createServer(cfgSockjs); sockjs_echo.on('connection', function (conn) { if (!conn) {