mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 07:29:08 +00:00
refract: async
ensure execution order by awaiting function calls
This commit is contained in:
+7
-5
@@ -26,12 +26,14 @@ const nodePath =
|
|||||||
const { startServer, startOSCServer, startOSCClient } = await import(
|
const { startServer, startOSCServer, startOSCClient } = await import(
|
||||||
nodePath
|
nodePath
|
||||||
);
|
);
|
||||||
// Start express server
|
|
||||||
loaded = startServer();
|
|
||||||
// Start OSC Server (API)
|
|
||||||
startOSCServer();
|
|
||||||
// Start OSC Client (Feedback)
|
// Start OSC Client (Feedback)
|
||||||
startOSCClient();
|
await startOSCClient();
|
||||||
|
|
||||||
|
// Start express server
|
||||||
|
loaded = await startServer();
|
||||||
|
|
||||||
|
// Start OSC Server (API)
|
||||||
|
await startOSCServer();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
loaded = error;
|
loaded = error;
|
||||||
|
|||||||
+26
-23
@@ -114,14 +114,36 @@ const oscInPort = s.oscInPort || config.osc.port;
|
|||||||
|
|
||||||
const serverPort = s.serverPort || config.server.port;
|
const serverPort = s.serverPort || config.server.port;
|
||||||
|
|
||||||
|
// Start OSC server
|
||||||
|
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
||||||
|
|
||||||
|
export const startOSCServer = async (overrideConfig = null) => {
|
||||||
|
// Setup default port
|
||||||
|
const oscSettings = {
|
||||||
|
port: overrideConfig?.port || oscInPort,
|
||||||
|
ipOut: oscIP,
|
||||||
|
portOut: oscOutPort,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Start OSC Server
|
||||||
|
initiateOSC(oscSettings);
|
||||||
|
};
|
||||||
|
|
||||||
// Start OSC Client
|
// Start OSC Client
|
||||||
// TODO: Move this to function
|
let oscClient = null;
|
||||||
const oscClient = new Client(oscIP, oscOutPort);
|
|
||||||
|
export const startOSCClient = async (overrideConfig = null) => {
|
||||||
|
// Setup default port
|
||||||
|
const port = overrideConfig?.port || oscOutPort;
|
||||||
|
console.log('initialise OSC Client on port: ', port);
|
||||||
|
|
||||||
|
oscClient = new Client(oscIP, oscOutPort);
|
||||||
|
};
|
||||||
|
|
||||||
// create HTTP server
|
// create HTTP server
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
export const startServer = (overrideConfig = null) => {
|
export const startServer = async (overrideConfig = null) => {
|
||||||
// Setup default port
|
// Setup default port
|
||||||
const port = overrideConfig?.port || serverPort;
|
const port = overrideConfig?.port || serverPort;
|
||||||
|
|
||||||
@@ -136,26 +158,7 @@ export const startServer = (overrideConfig = null) => {
|
|||||||
return returnMessage;
|
return returnMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start OSC server
|
export const shutdown = async () => {
|
||||||
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
|
||||||
|
|
||||||
export const startOSCServer = (overrideConfig = null) => {
|
|
||||||
// Setup default port
|
|
||||||
const oscSettings = {
|
|
||||||
port: overrideConfig?.port || oscInPort,
|
|
||||||
ipOut: oscIP,
|
|
||||||
portOut: oscOutPort,
|
|
||||||
};
|
|
||||||
initiateOSC(oscSettings);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const startOSCClient = (overrideConfig = null) => {
|
|
||||||
// Setup default port
|
|
||||||
const port = overrideConfig?.port || oscOutPort;
|
|
||||||
console.log('initialise OSC Client at port: ', port);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const shutdown = () => {
|
|
||||||
console.log('Node service shutdown');
|
console.log('Node service shutdown');
|
||||||
|
|
||||||
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
||||||
|
|||||||
Reference in New Issue
Block a user