2018-04-22 18:52:55 +00:00
|
|
|
/*
|
2018-04-22 20:16:38 +00:00
|
|
|
* Wazuh app - Module for server initialization
|
2020-01-22 14:53:03 +00:00
|
|
|
* Copyright (C) 2015-2020 Wazuh, Inc.
|
2018-04-22 18:52:55 +00:00
|
|
|
*
|
|
|
|
* 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';
|
|
|
|
import { Monitoring } from './server/monitoring';
|
|
|
|
import { WazuhApiRoutes } from './server/routes/wazuh-api';
|
2019-10-09 10:29:28 +00:00
|
|
|
import { WazuhHostsRoutes } from './server/routes/wazuh-hosts';
|
2018-09-10 08:32:49 +00:00
|
|
|
import { WazuhReportingRoutes } from './server/routes/wazuh-reporting';
|
2018-10-01 07:56:50 +00:00
|
|
|
import { WazuhUtilsRoutes } from './server/routes/wazuh-utils';
|
2020-08-04 07:40:10 +00:00
|
|
|
import { SchedulerHandler } from './server/lib/cron-scheduler'
|
2018-11-15 10:48:57 +00:00
|
|
|
import { log } from './server/logger';
|
2019-03-11 08:34:32 +00:00
|
|
|
import { Queue } from './server/jobs/queue';
|
2018-04-21 10:09:55 +00:00
|
|
|
|
2018-09-10 08:32:49 +00:00
|
|
|
export function initApp(server) {
|
2018-12-13 10:48:23 +00:00
|
|
|
const monitoringInstance = new Monitoring(server);
|
2020-08-04 07:40:10 +00:00
|
|
|
const schedulerHandler = new SchedulerHandler(server);
|
2019-04-15 10:47:45 +00:00
|
|
|
log('init:initApp', `Waiting for Kibana migration jobs`, 'debug');
|
2018-12-13 10:02:53 +00:00
|
|
|
server.kibanaMigrator
|
2019-12-17 09:33:07 +00:00
|
|
|
.runMigrations()
|
2018-12-13 10:02:53 +00:00
|
|
|
.then(() => {
|
|
|
|
log(
|
2019-04-15 10:47:45 +00:00
|
|
|
'init:initApp',
|
|
|
|
`Kibana migration jobs executed successfully`,
|
|
|
|
'debug'
|
2018-12-13 10:02:53 +00:00
|
|
|
);
|
|
|
|
Initialize(server);
|
|
|
|
WazuhElasticRouter(server);
|
2018-12-13 10:48:23 +00:00
|
|
|
monitoringInstance.run();
|
2020-08-04 07:40:10 +00:00
|
|
|
schedulerHandler.run();
|
2019-03-11 08:34:32 +00:00
|
|
|
Queue.launchCronJob();
|
2018-12-13 10:02:53 +00:00
|
|
|
WazuhApiRoutes(server);
|
2019-10-09 10:13:14 +00:00
|
|
|
WazuhHostsRoutes(server);
|
2018-12-13 10:02:53 +00:00
|
|
|
WazuhReportingRoutes(server);
|
|
|
|
WazuhUtilsRoutes(server);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2019-04-15 10:47:45 +00:00
|
|
|
log('init:initApp', error.message || error);
|
2018-12-13 10:02:53 +00:00
|
|
|
});
|
2018-09-10 08:32:49 +00:00
|
|
|
}
|