Skip to content

Commit

Permalink
Merge pull request #3417 from Countly/docker-changes
Browse files Browse the repository at this point in the history
[db] provide different configs for different databases through ENV va…
  • Loading branch information
ar2rsawseen authored Aug 9, 2022
2 parents 93ddcac + eaa6bd4 commit 46f083d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/pluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var pluginDependencies = require('./pluginDependencies.js'),
logDbRead = log('db:read'),
logDbWrite = log('db:write'),
exec = cp.exec,
spawn = cp.spawn;
spawn = cp.spawn,
configextender = require('../api/configextender');

/**
* This module handles communicaton with plugins
Expand Down Expand Up @@ -66,6 +67,15 @@ var pluginManager = function pluginManager() {
countly_fs: "../api/configs/config.db_fs.js"
};

/**
* Custom configuration files for different databases for docker env
*/
this.dbConfigEnvs = {
countly_drill: "PLUGINDRILL",
countly_out: "PLUGINOUT",
countly_fs: "PLUGINFS"
};

/**
* Initialize api side plugins
**/
Expand Down Expand Up @@ -1101,6 +1111,7 @@ var pluginManager = function pluginManager() {
if (typeof config === "string") {
db = config;
if (this.dbConfigFiles[config]) {
var confDb = config;
try {
//try loading custom config file
var conf = require(this.dbConfigFiles[config]);
Expand All @@ -1110,6 +1121,9 @@ var pluginManager = function pluginManager() {
//user default config
config = JSON.parse(JSON.stringify(countlyConfig));
}
if (this.dbConfigEnvs[config]) {
config = configextender(this.dbConfigEnvs[confDb], config, process.env);
}
}
else {
//user default config
Expand Down Expand Up @@ -1251,6 +1265,7 @@ var pluginManager = function pluginManager() {
if (typeof config === "string") {
db = config;
if (this.dbConfigFiles[config]) {
var confDb = config;
try {
//try loading custom config file
var conf = require(this.dbConfigFiles[config]);
Expand All @@ -1260,6 +1275,9 @@ var pluginManager = function pluginManager() {
//user default config
config = JSON.parse(JSON.stringify(countlyConfig));
}
if (this.dbConfigEnvs[config]) {
config = configextender(this.dbConfigEnvs[confDb], config, process.env);
}
}
else {
//user default config
Expand Down

0 comments on commit 46f083d

Please sign in to comment.