node-windows can't be loaded detection.
Ylian Saint-Hilaire committed
Oct 29, 2020 at 15:42 UTC
8f76a97329d195dc92cf1cd550bbbd92e1e1dc27
1 file changed
+5
-1
meshcentral.js
+5
-1
@@ -2782,7 +2782,11 @@ function mainStart() {
2782
if (config.settings.heapdump === true) { modules.push('heapdump'); }
2783
2784
// Install any missing modules and launch the server
2785
- InstallModules(modules, function () { meshserver = CreateMeshCentralServer(config, args); meshserver.Start(); });
2785
+ InstallModules(modules, function () {
2786
+ if (require('os').platform() == 'win32') { try { require('node-windows'); } catch (ex) { console.log("Module node-windows can't be loaded. Restart MeshCentral."); process.exit(); return; } }
2787
+ meshserver = CreateMeshCentralServer(config, args);
2788
+ meshserver.Start();
2789
+ });
2790
2791
// On exit, also terminate the child process if applicable
2792
process.on('exit', function () { if (childProcess) { childProcess.kill(); childProcess = null; } });