mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 16:49:41 +00:00
refactor: ensure start order (#322)
This commit is contained in:
+32
-26
@@ -29,14 +29,14 @@ let win;
|
|||||||
let splash;
|
let splash;
|
||||||
let tray = null;
|
let tray = null;
|
||||||
|
|
||||||
(async () => {
|
async function startBackend() {
|
||||||
// in dev mode, we expect both UI and server to be running
|
await (async () => {
|
||||||
if (!isProduction) {
|
// in dev mode, we expect both UI and server to be running
|
||||||
return;
|
if (!isProduction) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
const ontimeServer = require(nodePath);
|
||||||
const ontimeServer = require(nodePath)
|
|
||||||
const { initAssets, startServer, startOSCServer, startIntegrations } = ontimeServer;
|
const { initAssets, startServer, startOSCServer, startIntegrations } = ontimeServer;
|
||||||
|
|
||||||
await initAssets();
|
await initAssets();
|
||||||
@@ -44,10 +44,8 @@ let tray = null;
|
|||||||
loaded = await startServer();
|
loaded = await startServer();
|
||||||
await startOSCServer();
|
await startOSCServer();
|
||||||
await startIntegrations();
|
await startIntegrations();
|
||||||
} catch (error) {
|
})();
|
||||||
loaded = error;
|
}
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description utility function to create a notification
|
* @description utility function to create a notification
|
||||||
@@ -158,26 +156,34 @@ app.whenReady().then(() => {
|
|||||||
bringToFront();
|
bringToFront();
|
||||||
});
|
});
|
||||||
|
|
||||||
// cheat to schedule process
|
startBackend()
|
||||||
setTimeout(() => {
|
.then(() => {
|
||||||
// Load page served by node or use React dev run
|
// Load page served by node or use React dev run
|
||||||
const clientUrl = isProduction ? electronConfig.reactAppUrl.production : electronConfig.reactAppUrl.development;
|
const clientUrl = isProduction ? electronConfig.reactAppUrl.production : electronConfig.reactAppUrl.development;
|
||||||
|
|
||||||
win.loadURL(clientUrl).then(() => {
|
win
|
||||||
win.webContents.setBackgroundThrottling(false);
|
.loadURL(clientUrl)
|
||||||
|
.then(() => {
|
||||||
|
win.webContents.setBackgroundThrottling(false);
|
||||||
|
|
||||||
win.show();
|
win.show();
|
||||||
win.focus();
|
win.focus();
|
||||||
|
|
||||||
splash.destroy();
|
splash.destroy();
|
||||||
|
|
||||||
if (typeof loaded === 'string') {
|
if (typeof loaded === 'string') {
|
||||||
tray.setToolTip(loaded);
|
tray.setToolTip(loaded);
|
||||||
} else {
|
} else {
|
||||||
tray.setToolTip('Initialising error: please restart Ontime');
|
tray.setToolTip('Initialising error: please restart Ontime');
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
dialog.showErrorBox('Ontime failed to reach server', error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
dialog.showErrorBox('Ontime failed to start', error);
|
||||||
});
|
});
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// recreate window if no others open
|
// recreate window if no others open
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user