fix(server): unbreak workflow engine init - import fetchT, new NotificationManager, hoist servicesStateManager
Three cascading bugs in server.js's workflow engine init block: 1. fetchT was referenced but never imported from ./src/utils/http 2. notification-manager was called as factory function but the module now exports a class (NotificationManager) - need 'new' 3. servicesStateManager was referenced in workflowCtx but only created later inside an async IIFE (out of scope at workflow init time) Result: every container start logged Workflow engine failed to initialize - fetchT is not defined and the workflow engine never actually wired to resourceMonitor/ updateManager event sources. The 'app' context workflow engine still ran but didn't get those connections. Fix: - Import fetchT at top of file - Use 'new' for NotificationManager instantiation - Hoist servicesStateManager creation before workflow init and remove the duplicate inside the health-checker async IIFE Verified: container restart shows [server] Workflow engine initialized [ResourceMonitor] Workflow engine configured [UpdateManager] Workflow engine configured in the log, no more errors at startup. Also bumps VERSION to current SHA (bump from c64bbe2).
This commit is contained in:
@@ -1 +1 @@
|
||||
c64bbe2
|
||||
db14233
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Minimal startup script - all logic moved to src/
|
||||
*/
|
||||
const { createApp } = require('./src/app');
|
||||
const { fetchT } = require('./src/utils/http');
|
||||
const platformPaths = require('./platform-paths');
|
||||
|
||||
// Unhandled error handlers
|
||||
@@ -66,6 +67,10 @@ process.on('uncaughtException', (error) => {
|
||||
const selfUpdater = require('./self-updater');
|
||||
const portLockManager = require('./port-lock-manager');
|
||||
|
||||
// Create servicesStateManager early — needed by workflow engine init
|
||||
const StateManager = require('./state-manager');
|
||||
const servicesStateManager = new StateManager(SERVICES_FILE);
|
||||
|
||||
// Optional modules
|
||||
let dockerMaintenance, logDigest, bundledWorkflows;
|
||||
try { dockerMaintenance = require('./docker-maintenance'); } catch { /* optional */ }
|
||||
@@ -80,7 +85,7 @@ process.on('uncaughtException', (error) => {
|
||||
// Create a context with needed services
|
||||
const workflowCtx = {
|
||||
docker: { client: require('dockerode')() },
|
||||
notification: require('./notification-manager')({
|
||||
notification: new (require('./notification-manager'))({
|
||||
NOTIFICATIONS_FILE: process.env.NOTIFICATIONS_FILE || require('./platform-paths').notificationsFile,
|
||||
fetchT,
|
||||
log,
|
||||
@@ -133,9 +138,7 @@ process.on('uncaughtException', (error) => {
|
||||
(async () => {
|
||||
try {
|
||||
const { syncHealthCheckerServices } = require('./startup-validator');
|
||||
const StateManager = require('./state-manager');
|
||||
const servicesStateManager = new StateManager(SERVICES_FILE);
|
||||
|
||||
|
||||
await syncHealthCheckerServices({
|
||||
log,
|
||||
SERVICES_FILE,
|
||||
|
||||
Reference in New Issue
Block a user