* Loops through all modules and requests start for every module.
()
| 43 | * Loops through all modules and requests start for every module. |
| 44 | */ |
| 45 | async function startModules () { |
| 46 | const modulePromises = []; |
| 47 | for (const module of moduleObjects) { |
| 48 | try { |
| 49 | modulePromises.push(module.start()); |
| 50 | } catch (error) { |
| 51 | Log.error(`Error when starting node_helper for module ${module.name}:`); |
| 52 | Log.error(error); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | const results = await Promise.allSettled(modulePromises); |
| 57 | |
| 58 | // Log errors that happened during async node_helper startup |
| 59 | results.forEach((result) => { |
| 60 | if (result.status === "rejected") { |
| 61 | Log.error(result.reason); |
| 62 | } |
| 63 | }); |
| 64 | |
| 65 | // Notify core of loaded modules. |
| 66 | MM.modulesStarted(moduleObjects); |
| 67 | |
| 68 | // Starting modules also hides any modules that have requested to be initially hidden |
| 69 | for (const thisModule of moduleObjects) { |
| 70 | if (thisModule.data.hiddenOnStartup) { |
| 71 | Log.info(`Initially hiding ${thisModule.name}`); |
| 72 | thisModule.hide(); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Retrieve list of all modules. |
no test coverage detected