mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +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(
|
||||
nodePath
|
||||
);
|
||||
// Start express server
|
||||
loaded = startServer();
|
||||
// Start OSC Server (API)
|
||||
startOSCServer();
|
||||
// Start OSC Client (Feedback)
|
||||
startOSCClient();
|
||||
await startOSCClient();
|
||||
|
||||
// Start express server
|
||||
loaded = await startServer();
|
||||
|
||||
// Start OSC Server (API)
|
||||
await startOSCServer();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loaded = error;
|
||||
|
||||
+26
-23
@@ -114,14 +114,36 @@ const oscInPort = s.oscInPort || config.osc.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
|
||||
// TODO: Move this to function
|
||||
const oscClient = new Client(oscIP, oscOutPort);
|
||||
let oscClient = null;
|
||||
|
||||
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
|
||||
const server = http.createServer(app);
|
||||
|
||||
export const startServer = (overrideConfig = null) => {
|
||||
export const startServer = async (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const port = overrideConfig?.port || serverPort;
|
||||
|
||||
@@ -136,26 +158,7 @@ export const startServer = (overrideConfig = null) => {
|
||||
return returnMessage;
|
||||
};
|
||||
|
||||
// Start OSC server
|
||||
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 = () => {
|
||||
export const shutdown = async () => {
|
||||
console.log('Node service shutdown');
|
||||
|
||||
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
||||
|
||||
Reference in New Issue
Block a user