Browse Source

metrics db path usage fix

pull/1/head
Alexey Velikiy 6 years ago
parent
commit
00e09cfe22
  1. 7
      server/src/config.ts
  2. 2
      server/src/index.ts
  3. 2
      server/src/services/data_service.ts
  4. 10
      server/src/services/process_service.ts

7
server/src/config.ts

@ -10,16 +10,11 @@ export const ANALYTICS_PATH = path.join(__dirname, '../../analytics');
export const DATA_PATH = path.join(__dirname, '../../data'); export const DATA_PATH = path.join(__dirname, '../../data');
export const ANALYTIC_UNITS_DATABASE_PATH = path.join(DATA_PATH, 'analyticUnits.db'); export const ANALYTIC_UNITS_DATABASE_PATH = path.join(DATA_PATH, 'analytic_units.db');
export const METRICS_DATABASE_PATH = path.join(DATA_PATH, 'metrics.db'); export const METRICS_DATABASE_PATH = path.join(DATA_PATH, 'metrics.db');
export const SEGMENTS_DATABASE_PATH = path.join(DATA_PATH, 'segments.db'); export const SEGMENTS_DATABASE_PATH = path.join(DATA_PATH, 'segments.db');
export const FILES_DATABASE_PATH = path.join(DATA_PATH, 'files.db'); export const FILES_DATABASE_PATH = path.join(DATA_PATH, 'files.db');
export const DATASETS_PATH = path.join(DATA_PATH, 'datasets');
export const MODELS_PATH = path.join(DATA_PATH, 'models');
export const METRICS_PATH = path.join(DATA_PATH, 'metrics');
export const SEGMENTS_PATH = path.join(DATA_PATH, 'segments');
export const HASTIC_PORT = getConfigField('HASTIC_PORT', '8000'); export const HASTIC_PORT = getConfigField('HASTIC_PORT', '8000');
export const ZMQ_CONNECTION_STRING = getConfigField('ZMQ_CONNECTION_STRING', null); export const ZMQ_CONNECTION_STRING = getConfigField('ZMQ_CONNECTION_STRING', null);
export const ZMQ_IPC_PATH = getConfigField('ZMQ_IPC_PATH', path.join('/tmp', 'hastic')); export const ZMQ_IPC_PATH = getConfigField('ZMQ_IPC_PATH', path.join('/tmp', 'hastic'));

2
server/src/index.ts

@ -1,6 +1,6 @@
import { router as anomaliesRouter } from './routes/analytic_units_router'; import { router as anomaliesRouter } from './routes/analytic_units_router';
import { router as segmentsRouter } from './routes/segments_router'; import { router as segmentsRouter } from './routes/segments_router';
//import { router as alertsRouter } from './routes/alerts_router';
import * as AnalyticsController from './controllers/analytics_controller'; import * as AnalyticsController from './controllers/analytics_controller';

2
server/src/services/data_service.ts

@ -120,5 +120,5 @@ checkDataFolders();
// TODO: it's better if models request db which we create if it`s needed // TODO: it's better if models request db which we create if it`s needed
db[Collection.ANALYTIC_UNITS] = new nedb({ filename: config.ANALYTIC_UNITS_DATABASE_PATH, autoload: true }); db[Collection.ANALYTIC_UNITS] = new nedb({ filename: config.ANALYTIC_UNITS_DATABASE_PATH, autoload: true });
db[Collection.METRICS] = new nedb({ filename: config.ANALYTIC_UNITS_DATABASE_PATH, autoload: true }); db[Collection.METRICS] = new nedb({ filename: config.METRICS_DATABASE_PATH, autoload: true });
db[Collection.SEGMENTS] = new nedb({ filename: config.SEGMENTS_DATABASE_PATH, autoload: true }); db[Collection.SEGMENTS] = new nedb({ filename: config.SEGMENTS_DATABASE_PATH, autoload: true });

10
server/src/services/process_service.ts

@ -12,7 +12,7 @@ export function registerExitHandler(callback: () => void) {
exitHandlers.push(callback); exitHandlers.push(callback);
} }
function exitHandler(options, err) { function exitHandler(options, err?) {
if(exitHandled) { if(exitHandled) {
return; return;
} }
@ -24,6 +24,12 @@ function exitHandler(options, err) {
process.exit(); process.exit();
} }
function catchException(options, err) {
console.log('Server exception:');
console.log(err);
exitHandler({ exit: true });
}
//do something when app is closing //do something when app is closing
process.on('exit', exitHandler.bind(null, { cleanup:true })); process.on('exit', exitHandler.bind(null, { cleanup:true }));
@ -35,4 +41,4 @@ process.on('SIGUSR1', exitHandler.bind(null, {exit:true}));
process.on('SIGUSR2', exitHandler.bind(null, { exit:true })); process.on('SIGUSR2', exitHandler.bind(null, { exit:true }));
//catches uncaught exceptions //catches uncaught exceptions
process.on('uncaughtException', exitHandler.bind(null, {exit:true})); process.on('uncaughtException', catchException.bind(null, { exit:true }));
Loading…
Cancel
Save