-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (31 loc) · 880 Bytes
/
index.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
// index.js
"use strict";
const { ServiceBroker } = require("moleculer");
const { validateEnv, config } = require("./bootstrap");
// Validiere Umgebungsvariablen bevor die Anwendung startet
validateEnv();
// Erstelle den ServiceBroker
const broker = new ServiceBroker({
namespace: config.serviceName,
transporter: config.nats.url,
logger: config.logging,
// Weitere Moleculer-Konfiguration...
});
// Lade alle Services
broker.loadServices("./services", "**/*.service.js");
// Starte den Broker
broker.start()
.then(() => {
broker.logger.info("All services started successfully");
})
.catch(err => {
broker.logger.error("Error starting services:", err);
process.exit(1);
});
// Handle process termination
process.on("SIGTERM", () => {
broker.stop()
.then(() => {
process.exit(0);
});
});