You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

7 years ago
import * as path from 'path';
import * as fs from 'fs';
import { getJsonDataSync } from './services/json';
let configFile = path.join(__dirname, '../../config.json');
let configExists = fs.existsSync(configFile);
7 years ago
export const ANALYTICS_PATH = path.join(__dirname, '../../analytics');
7 years ago
export const DATA_PATH = path.join(__dirname, '../../data');
7 years ago
export const DATASETS_PATH = path.join(DATA_PATH, 'datasets');
export const ANOMALIES_PATH = path.join(DATA_PATH, 'anomalies');
7 years ago
export const MODELS_PATH = path.join(DATA_PATH, 'models');
export const METRICS_PATH = path.join(DATA_PATH, 'metrics');
7 years ago
export const SEGMENTS_PATH = path.join(DATA_PATH, 'segments');
export const HASTIC_PORT = getConfigField('HASTIC_PORT', '8000');
export const ZEROMQ_CONNECTION_STRING = getConfigField('ZEROMQ_CONNECTION_STRING', 'tcp://127.0.0.1:8002');
function getConfigField(field, defaultVal?) {
let val = defaultVal;
if(process.env[field] !== undefined) {
val = process.env[field];
} else if(configExists) {
let config: any = getJsonDataSync(configFile);
if(config[field] !== undefined) {
val = config[field];
}
}
if(val === undefined) {
throw new Error(`Please configure ${field}`);
}
return val;
}