Generate storage profile dynamically

This commit is contained in:
Mikunj 2020-03-26 15:42:26 +11:00
parent 6d87904d18
commit 5f98f702d4
9 changed files with 23 additions and 19 deletions

View File

@ -36,11 +36,11 @@ config.environment = environment;
// Log resulting env vars in use by config
[
'NODE_ENV',
'NODE_APP_INSTANCE',
'NODE_CONFIG_DIR',
'NODE_CONFIG',
'ALLOW_CONFIG_MUTATIONS',
'HOSTNAME',
'NODE_APP_INSTANCE',
'SUPPRESS_NO_CONFIG_WARNING',
].forEach(s => {
console.log(`${s} ${config.util.getEnv(s)}`);

View File

@ -1,15 +1,30 @@
const path = require('path');
const process = require('process');
const { app } = require('electron');
const { start } = require('./base_config');
const config = require('./config');
// Use separate data directory for development
if (config.has('storageProfile')) {
let storageProfile;
const { NODE_ENV: environment, NODE_APP_INSTANCE:instance } = process.env;
const isProduction = environment === 'production' && !instance;
// Use seperate data directories for each different environment and app instances
// We should prioritise config values first
if (config.has(storageProfile)) {
storageProfile = config.get('storageProfile');
} else if (!isProduction) {
storageProfile = environment;
if (instance) {
storageProfile = storageProfile.concat(`-${instance}`)
}
}
if (storageProfile) {
const userData = path.join(
app.getPath('appData'),
`Loki-Messenger-${config.get('storageProfile')}`
`Session-${storageProfile}`
);
app.setPath('userData', userData);

View File

@ -1,3 +0,0 @@
{
"storageProfile": "development1"
}

View File

@ -1,5 +1,4 @@
{
"storageProfile": "development",
"seedNodeList": [
{
"ip": "public.loki.foundation",

View File

@ -1,6 +0,0 @@
{
"storageProfile": "devprod1Profile",
"localServerPort": "8082",
"openDevTools": true,
"updatesEnabled": false
}

View File

@ -1,5 +1,4 @@
{
"storageProfile": "devprodProfile",
"openDevTools": true,
"updatesEnabled": false
}

View File

@ -0,0 +1,4 @@
{
"openDevTools": true,
"updatesEnabled": false
}

View File

@ -1,3 +0,0 @@
{
"storageProfile": "swarm-testing2"
}

View File

@ -1,5 +1,4 @@
{
"storageProfile": "swarm-testing",
"seedNodeList": [
{
"ip": "localhost",