diff --git a/packages/noodl-editor/src/main/main.js b/packages/noodl-editor/src/main/main.js index 1e93e66..4598598 100644 --- a/packages/noodl-editor/src/main/main.js +++ b/packages/noodl-editor/src/main/main.js @@ -7,6 +7,7 @@ const AutoUpdater = require('./src/autoupdater'); const FloatingWindow = require('./src/floating-window'); const startServer = require('./src/web-server'); const { startCloudFunctionServer, closeRuntimeWhenWindowCloses } = require('./src/cloud-function-server'); +const { setupBackendIPC, backendManager } = require('./src/local-backend'); const DesignToolImportServer = require('./src/design-tool-import-server'); const jsonstorage = require('../shared/utils/jsonstorage'); const StorageApi = require('./src/StorageApi'); @@ -555,6 +556,9 @@ function launchApp() { startCloudFunctionServer(app, cloudServicesGetActive); closeRuntimeWhenWindowCloses(win); + // Initialize local backend IPC handlers + setupBackendIPC(); + DesignToolImportServer.start(projectGetInfo); try { @@ -587,6 +591,15 @@ function launchApp() { } }); + // Stop all local backends on quit + app.on('before-quit', async () => { + try { + await backendManager.stopAll(); + } catch (e) { + console.log('Error stopping backends:', e); + } + }); + app.on('activate', () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open.