wazuh-kibana-app/init.js

55 lines
1.8 KiB
JavaScript
Raw Normal View History

/*
* Wazuh app - Module for server initialization
2019-01-14 16:36:47 +00:00
* Copyright (C) 2015-2019 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/
2018-05-16 21:58:50 +00:00
// Imports all server modules
2018-09-10 08:32:49 +00:00
import { Initialize } from './server/initialize';
import { WazuhElasticRouter } from './server/routes/wazuh-elastic';
2018-09-03 09:46:55 +00:00
import { WazuhApiElasticRoutes } from './server/routes/wazuh-api-elastic';
2018-09-10 08:32:49 +00:00
import { Monitoring } from './server/monitoring';
import { WazuhApiRoutes } from './server/routes/wazuh-api';
import { WazuhReportingRoutes } from './server/routes/wazuh-reporting';
2018-10-01 07:56:50 +00:00
import { WazuhUtilsRoutes } from './server/routes/wazuh-utils';
2019-03-01 15:32:48 +00:00
import { IndexPatternCronJob } from './server/index-pattern-cron-job';
import { log } from './server/logger';
import { Queue } from './server/jobs/queue';
2018-09-10 08:32:49 +00:00
export function initApp(server) {
const monitoringInstance = new Monitoring(server);
2019-03-01 15:32:48 +00:00
const indexPatternCronJobInstance = new IndexPatternCronJob(server);
2018-12-13 10:02:53 +00:00
log('[initApp]', `Waiting for awaitMigration()`, 'info');
server.kibanaMigrator
.awaitMigration()
.then(() => {
log(
'[initApp]',
`awaitMigration() has been executed successfully`,
'info'
);
Initialize(server);
WazuhElasticRouter(server);
WazuhApiElasticRoutes(server);
monitoringInstance.run();
2019-03-01 15:32:48 +00:00
indexPatternCronJobInstance.run();
Queue.launchCronJob();
2018-12-13 10:02:53 +00:00
WazuhApiRoutes(server);
WazuhReportingRoutes(server);
WazuhUtilsRoutes(server);
})
.catch(error => {
log(
'[initApp]',
`initApp function failed due to: ${error.message || error}`
);
});
2018-09-10 08:32:49 +00:00
}