Generate storage profile dynamically
This commit is contained in:
parent
6d87904d18
commit
5f98f702d4
|
@ -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)}`);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"storageProfile": "development1"
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
"storageProfile": "development",
|
||||
"seedNodeList": [
|
||||
{
|
||||
"ip": "public.loki.foundation",
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"storageProfile": "devprod1Profile",
|
||||
"localServerPort": "8082",
|
||||
"openDevTools": true,
|
||||
"updatesEnabled": false
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
"storageProfile": "devprodProfile",
|
||||
"openDevTools": true,
|
||||
"updatesEnabled": false
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"openDevTools": true,
|
||||
"updatesEnabled": false
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"storageProfile": "swarm-testing2"
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
"storageProfile": "swarm-testing",
|
||||
"seedNodeList": [
|
||||
{
|
||||
"ip": "localhost",
|
||||
|
|
Loading…
Reference in New Issue