Files
pulse-signage/src/web/lib/web-startup.js
T
lzstealth 3f4f57020a
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m13s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s
Release v2.10.3
2026-08-29 01:56:45 +01:00

38 lines
1.8 KiB
JavaScript

// Start background services, scheduled tasks, and web application dependencies.
async function initializeWebServer(options) {
const common = options && options.common;
const pool = options && options.pool;
const mediaDir = String(options && options.mediaDir || '').trim();
const backgroundTaskQueue = options && options.backgroundTaskQueue;
const webBootstrap = options && options.webBootstrap;
const loadCurrentUser = options && options.loadCurrentUser;
const initializeBackgroundTasks = options && options.initializeBackgroundTasks;
const captureSlideThumbnail = options && options.captureSlideThumbnail;
const dataSourceStartupRefreshStaggerMs = Math.max(100, Number(options && options.dataSourceStartupRefreshStaggerMs || 250));
const server = options && options.server;
if (!common || !pool || !mediaDir || !backgroundTaskQueue || !webBootstrap || typeof loadCurrentUser !== 'function' || typeof initializeBackgroundTasks !== 'function' || typeof captureSlideThumbnail !== 'function' || !server) {
throw new Error('initializeWebServer requires the web startup dependencies.');
}
await common.ensureSchema(pool, { mediaDir: mediaDir });
await common.bootstrapDatabase(pool);
await backgroundTaskQueue.initialize();
await initializeBackgroundTasks({
pool: pool,
common: common,
backgroundTaskQueue: backgroundTaskQueue,
notifyPlayerScreens: options && options.notifyPlayerScreens ? options.notifyPlayerScreens : null,
uploadSyncService: webBootstrap.uploadSyncService,
captureSlideThumbnail: captureSlideThumbnail,
mediaDir: mediaDir,
webBaseUrl: options && options.webBaseUrl ? options.webBaseUrl : null,
dataSourceStartupRefreshStaggerMs: dataSourceStartupRefreshStaggerMs
});
webBootstrap.installDashboardWebsocket(server, loadCurrentUser);
}
module.exports = { initializeWebServer };