forked from wazuh/wazuh-dashboard-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
51 lines (48 loc) · 1.77 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Wazuh app - Module for server initialization
* Copyright (C) 2015-2020 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.
*/
// Imports all server modules
import { Initialize } from './server/initialize';
import { WazuhElasticRouter } from './server/routes/wazuh-elastic';
import { Monitoring } from './server/monitoring';
import { WazuhApiRoutes } from './server/routes/wazuh-api';
import { WazuhHostsRoutes } from './server/routes/wazuh-hosts';
import { WazuhReportingRoutes } from './server/routes/wazuh-reporting';
import { WazuhUtilsRoutes } from './server/routes/wazuh-utils';
import { IndexPatternCronJob } from './server/index-pattern-cron-job';
import { log } from './server/logger';
import { Queue } from './server/jobs/queue';
export function initApp(server) {
const monitoringInstance = new Monitoring(server);
const indexPatternCronJobInstance = new IndexPatternCronJob(server);
log('init:initApp', `Waiting for Kibana migration jobs`, 'debug');
server.kibanaMigrator
.runMigrations()
.then(() => {
log(
'init:initApp',
`Kibana migration jobs executed successfully`,
'debug'
);
Initialize(server);
WazuhElasticRouter(server);
monitoringInstance.run();
indexPatternCronJobInstance.run();
Queue.launchCronJob();
WazuhApiRoutes(server);
WazuhHostsRoutes(server);
WazuhReportingRoutes(server);
WazuhUtilsRoutes(server);
})
.catch(error => {
log('init:initApp', error.message || error);
});
}