Работа над RemoteLib
This commit is contained in:
@@ -2,7 +2,6 @@ const path = require('path');
|
||||
const pckg = require('../../package.json');
|
||||
|
||||
const execDir = path.resolve(__dirname, '..');
|
||||
const dataDir = `${execDir}/.${pckg.name}`;
|
||||
|
||||
module.exports = {
|
||||
branch: 'unknown',
|
||||
@@ -10,10 +9,6 @@ module.exports = {
|
||||
name: pckg.name,
|
||||
|
||||
execDir,
|
||||
dataDir,
|
||||
tempDir: `${dataDir}/tmp`,
|
||||
logDir: `${dataDir}/log`,
|
||||
publicDir: `${dataDir}/public`,
|
||||
|
||||
accessPassword: '',
|
||||
bookReadLink: '',
|
||||
@@ -27,6 +22,16 @@ module.exports = {
|
||||
|
||||
webConfigParams: ['name', 'version', 'branch', 'bookReadLink'],
|
||||
|
||||
allowRemoteLib: false,
|
||||
remoteLib: false,
|
||||
/*
|
||||
allowRemoteLib: true, // на сервере
|
||||
remoteLib: { // на клиенте
|
||||
accessPassword: '',
|
||||
url: 'wss://remoteInpxWeb.ru',
|
||||
},
|
||||
*/
|
||||
|
||||
server: {
|
||||
ip: '0.0.0.0',
|
||||
port: '22380',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const _ = require('lodash');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const branchFilename = __dirname + '/application_env';
|
||||
@@ -12,6 +13,8 @@ const propsToSave = [
|
||||
'cacheCleanInterval',
|
||||
'inpxCheckInterval',
|
||||
'lowMemoryMode',
|
||||
'allowRemoteLib',
|
||||
'remoteLib',
|
||||
'server',
|
||||
];
|
||||
|
||||
@@ -29,7 +32,7 @@ class ConfigManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
async init() {
|
||||
async init(dataDir) {
|
||||
if (this.inited)
|
||||
throw new Error('already inited');
|
||||
|
||||
@@ -44,10 +47,17 @@ class ConfigManager {
|
||||
process.env.NODE_ENV = this.branch;
|
||||
|
||||
this.branchConfigFile = __dirname + `/${this.branch}.js`;
|
||||
this._config = require(this.branchConfigFile);
|
||||
const config = require(this.branchConfigFile);
|
||||
|
||||
await fs.ensureDir(this._config.dataDir);
|
||||
this._userConfigFile = `${this._config.dataDir}/config.json`;
|
||||
if (dataDir) {
|
||||
config.dataDir = path.resolve(dataDir);
|
||||
} else {
|
||||
config.dataDir = `${config.execDir}/.${config.name}`;
|
||||
}
|
||||
|
||||
await fs.ensureDir(config.dataDir);
|
||||
this._userConfigFile = `${config.dataDir}/config.json`;
|
||||
this._config = config;
|
||||
|
||||
this.inited = true;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
const path = require('path');
|
||||
const pckg = require('../../package.json');
|
||||
const base = require('./base');
|
||||
|
||||
const execDir = path.dirname(process.execPath);
|
||||
const dataDir = `${execDir}/.${pckg.name}`;
|
||||
|
||||
module.exports = Object.assign({}, base, {
|
||||
branch: 'production',
|
||||
|
||||
execDir,
|
||||
dataDir,
|
||||
tempDir: `${dataDir}/tmp`,
|
||||
logDir: `${dataDir}/log`,
|
||||
publicDir: `${dataDir}/public`,
|
||||
|
||||
server: {
|
||||
ip: '0.0.0.0',
|
||||
|
||||
Reference in New Issue
Block a user