mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
refactor(backend): Trigger webserver events in webserver
We were triggering webserver events in Kernel. This change improves adherence to separation-of-concerns and ensures event cascading is working as expected. This also better formalizes the boot sequence.
This commit is contained in:
parent
89ac491120
commit
d800b12569
@ -152,17 +152,7 @@ class Kernel extends AdvancedBase {
|
||||
const { services } = this;
|
||||
|
||||
await services.ready;
|
||||
{
|
||||
const app = services.get('web-server').app;
|
||||
app.use(async (req, res, next) => {
|
||||
req.services = services;
|
||||
next();
|
||||
});
|
||||
await services.emit('boot.services-initialized');
|
||||
await services.emit('install.middlewares.context-aware', { app });
|
||||
await services.emit('install.routes', { app });
|
||||
await services.emit('install.routes-gui', { app });
|
||||
}
|
||||
await services.emit('boot.consolidation');
|
||||
|
||||
// === END: Initialize Service Registry ===
|
||||
|
||||
@ -178,9 +168,8 @@ class Kernel extends AdvancedBase {
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
await services.emit('start.webserver');
|
||||
await services.emit('ready.webserver');
|
||||
await services.emit('boot.activation');
|
||||
await services.emit('boot.ready');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ const { Context } = require("../util/context");
|
||||
const BaseService = require("./BaseService");
|
||||
|
||||
class RefreshAssociationsService extends BaseService {
|
||||
async ['__on_boot.services-initialized'] () {
|
||||
async ['__on_boot.consolidation'] () {
|
||||
const { refresh_associations_cache } = require('../helpers');
|
||||
|
||||
await Context.allow_fallback(async () => {
|
||||
|
@ -42,6 +42,20 @@ class WebServerService extends BaseService {
|
||||
morgan: require('morgan'),
|
||||
};
|
||||
|
||||
async ['__on_boot.consolidation'] () {
|
||||
const app = this.app;
|
||||
const services = this.services;
|
||||
await services.emit('install.middlewares.context-aware', { app });
|
||||
await services.emit('install.routes', { app });
|
||||
await services.emit('install.routes-gui', { app });
|
||||
}
|
||||
|
||||
async ['__on_boot.activation'] () {
|
||||
const services = this.services;
|
||||
await services.emit('start.webserver');
|
||||
await services.emit('ready.webserver');
|
||||
}
|
||||
|
||||
async ['__on_start.webserver'] () {
|
||||
await es_import_promise;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user