|
|
|
@ -123,14 +123,13 @@ module.getRedisKeys = (pattern) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.loadServices = async (dtp) => {
|
|
|
|
|
dtp.services = module.services = { };
|
|
|
|
|
dtp.services = { };
|
|
|
|
|
const scripts = glob.sync(path.join(dtp.config.root, 'app', 'services', '*.js'));
|
|
|
|
|
const inits = [ ];
|
|
|
|
|
await SiteAsync.each(scripts, async (script) => {
|
|
|
|
|
const service = await require(script);
|
|
|
|
|
module.services[service.name] = service.create(dtp);
|
|
|
|
|
module.services[service.name].__dtp_service_name = service.name;
|
|
|
|
|
inits.push(module.services[service.name]);
|
|
|
|
|
dtp.services[service.index] = service.create(dtp);
|
|
|
|
|
inits.push(dtp.services[service.index]);
|
|
|
|
|
});
|
|
|
|
|
await SiteAsync.each(inits, async (service) => {
|
|
|
|
|
await service.start();
|
|
|
|
@ -146,8 +145,12 @@ module.loadControllers = async (dtp) => {
|
|
|
|
|
await SiteAsync.each(scripts, async (script) => {
|
|
|
|
|
const controller = await require(script);
|
|
|
|
|
controller.instance = await controller.create(dtp);
|
|
|
|
|
module.log.info('controller loaded', { name: controller.name, slug: controller.slug });
|
|
|
|
|
dtp.controllers[controller.name] = controller;
|
|
|
|
|
module.log.info('controller loaded', {
|
|
|
|
|
logId: controller.logId,
|
|
|
|
|
index: controller.index,
|
|
|
|
|
className: controller.className,
|
|
|
|
|
});
|
|
|
|
|
dtp.controllers[controller.index] = controller;
|
|
|
|
|
|
|
|
|
|
inits.push(controller);
|
|
|
|
|
});
|
|
|
|
@ -180,7 +183,7 @@ module.loadControllers = async (dtp) => {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports.startPlatform = async (dtp) => {
|
|
|
|
|
module.exports.start = async (dtp) => {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
module.log = new SiteLog(module, dtp.config.component);
|
|
|
|
@ -343,9 +346,9 @@ module.exports.startWebServer = async (dtp) => {
|
|
|
|
|
module.app.use(passport.initialize());
|
|
|
|
|
module.app.use(passport.session());
|
|
|
|
|
|
|
|
|
|
module.services.oauth2.registerPassport();
|
|
|
|
|
module.app.use(module.services.session.middleware());
|
|
|
|
|
module.app.use(module.services.userNotification.middleware({ withNotifications: false }));
|
|
|
|
|
dtp.services.oauth2.registerPassport();
|
|
|
|
|
module.app.use(dtp.services.session.middleware());
|
|
|
|
|
module.app.use(dtp.services.userNotification.middleware({ withNotifications: false }));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Application logic middleware
|
|
|
|
@ -412,17 +415,16 @@ module.exports.startWebServer = async (dtp) => {
|
|
|
|
|
await module.createHttpsServer(dtp, module.app);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// prefer to attach Socket.io to the HTTPS server and fall back to HTTP
|
|
|
|
|
await module.createSocketServer(dtp, module.https || module.http);
|
|
|
|
|
|
|
|
|
|
if (module.http) {
|
|
|
|
|
await module.createSocketServer(dtp, module.http);
|
|
|
|
|
await module.startHttpServer(dtp, module.http, dtp.config.http);
|
|
|
|
|
}
|
|
|
|
|
if (module.https) {
|
|
|
|
|
await module.createSocketServer(dtp, module.https);
|
|
|
|
|
await module.startHttpServer(dtp, module.https, dtp.config.https);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.log.info(`${dtp.config.component.name} platform online`, {
|
|
|
|
|
module.log.info(`${dtp.config.component.className} platform online`, {
|
|
|
|
|
http: dtp.config.http.port,
|
|
|
|
|
https: dtp.config.https.port,
|
|
|
|
|
});
|
|
|
|
|