[license] Return original license on 'license' command

This commit is contained in:
Sergey Konovalov
2021-06-03 13:27:05 +03:00
committed by Sergey Konovalov
parent 2e8c3e2402
commit fd96e01687
4 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,7 @@ const oBuildDate = new Date(buildDate);
exports.readLicense = function*() {
const c_LR = constants.LICENSE_RESULT;
return {
return [{
count: 1,
type: c_LR.Success,
light: false,
@ -54,7 +54,7 @@ exports.readLicense = function*() {
plugins: false,
buildDate: oBuildDate,
endDate: null
};
}, null];
};
exports.packageType = constants.PACKAGE_TYPE_OS;

View File

@ -165,6 +165,7 @@ let lockDocumentsTimerId = {};//to drop connection that can't unlockDocument
let pubsub;
let queue;
let licenseInfo = {type: constants.LICENSE_RESULT.Error, light: false, branding: false, customization: false, plugins: false};
let licenseOriginal = null;
let shutdownFlag = false;
let expDocumentsStep = gc.getCronStep(cfgExpDocumentsCron);
@ -3132,8 +3133,9 @@ exports.install = function(server, callbackFunction) {
});
});
};
exports.setLicenseInfo = function(data) {
exports.setLicenseInfo = function(data, original ) {
licenseInfo = data;
licenseOriginal = original;
};
exports.getLicenseInfo = function() {
return licenseInfo;
@ -3273,7 +3275,7 @@ let commandLicense = co.wrap(function*() {
const nowUTC = getLicenseNowUtc();
let users = yield editorData.getPresenceUniqueUser(nowUTC);
return {
license: utils.convertLicenseInfoToFileParams(licenseInfo),
license: licenseOriginal || utils.convertLicenseInfoToFileParams(licenseInfo),
server: utils.convertLicenseInfoToServerParams(licenseInfo),
quota: {users: users}
};

View File

@ -63,7 +63,7 @@ app.set("views", cfgHtmlTemplate);
app.set("view engine", "ejs");
const server = http.createServer(app);
let licenseInfo, updatePluginsTime, userPlugins, pluginsLoaded;
let licenseInfo, licenseOriginal, updatePluginsTime, userPlugins, pluginsLoaded;
const updatePlugins = (eventType, filename) => {
console.log('update Folder: %s ; %s', eventType, filename);
@ -75,13 +75,13 @@ const updatePlugins = (eventType, filename) => {
pluginsLoaded = false;
};
const readLicense = function*() {
licenseInfo = yield* license.readLicense();
[licenseInfo, licenseOriginal] = yield* license.readLicense();
};
const updateLicense = () => {
return co(function*() {
try {
yield* readLicense();
docsCoServer.setLicenseInfo(licenseInfo);
docsCoServer.setLicenseInfo(licenseInfo, licenseOriginal);
console.log('End updateLicense');
} catch (err) {
logger.error('updateLicense error:\r\n%s', err.stack);

View File

@ -46,7 +46,7 @@ if (cluster.isMaster) {
const cfgMaxProcessCount = config.get('maxprocesscount');
var licenseInfo, workersCount = 0;
const readLicense = function* () {
licenseInfo = yield* license.readLicense();
[licenseInfo] = yield* license.readLicense();
workersCount = Math.min(licenseInfo.count, Math.ceil(numCPUs * cfgMaxProcessCount));
};
const updateWorkers = () => {