Files
pulse-signage/src/web/lib/web-startup.js
T
lzstealth 0a03cdd0b7
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 2m6s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 33s
Release v2.12.0
2026-09-11 17:22:31 +01:00

42 lines
2.1 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 forwardPlayerCommandToDevice = options && options.forwardPlayerCommandToDevice;
const localPlayerInternalUrl = options && options.localPlayerInternalUrl;
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,
forwardPlayerCommandToDevice: forwardPlayerCommandToDevice,
uploadSyncService: webBootstrap.uploadSyncService,
captureSlideThumbnail: captureSlideThumbnail,
mediaDir: mediaDir,
localPlayerInternalUrl: localPlayerInternalUrl,
webBaseUrl: options && options.webBaseUrl ? options.webBaseUrl : null,
dataSourceStartupRefreshStaggerMs: dataSourceStartupRefreshStaggerMs
});
webBootstrap.installDashboardWebsocket(server, loadCurrentUser);
}
module.exports = { initializeWebServer };