mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
separe init processes
separate processes to initialise: - express server - osc server - osc client
This commit is contained in:
+9
-3
@@ -15,9 +15,15 @@ const { Notification } = require('electron');
|
||||
const env = process.env.NODE_ENV || 'prod';
|
||||
|
||||
(async () => {
|
||||
const { nodeapp } = import(
|
||||
const { startServer, startOSCServer, startOSCClient } = await import(
|
||||
path.join('file:///', __dirname, env == 'prod' ? '../' : '', 'src/app.js')
|
||||
);
|
||||
// Start express server
|
||||
startServer();
|
||||
// Start OSC Server (API)
|
||||
startOSCServer();
|
||||
// Start OSC Client (Feedback)
|
||||
startOSCClient();
|
||||
})();
|
||||
|
||||
// Load Icons
|
||||
@@ -62,7 +68,7 @@ function createWindow() {
|
||||
|
||||
win = new BrowserWindow({
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
height: 1000,
|
||||
minWidth: 500,
|
||||
minHeight: 530,
|
||||
maxWidth: 1920,
|
||||
@@ -199,7 +205,7 @@ ipcMain.on('set-window', (event, arg) => {
|
||||
|
||||
if (arg === 'to-max') {
|
||||
// window full
|
||||
win.setContentSize(1920, 1080);
|
||||
win.setContentSize(1920, 1000);
|
||||
win.setPosition(0, 0);
|
||||
} else if (arg === 'to-tray') {
|
||||
// window to tray
|
||||
|
||||
+37
-17
@@ -10,7 +10,7 @@ import { fileURLToPath } from 'url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
var env = process.env.NODE_ENV || 'prod';
|
||||
const env = process.env.NODE_ENV || 'prod';
|
||||
|
||||
const file = join(__dirname, 'data/', config.database.filename);
|
||||
const adapter = new JSONFile(file);
|
||||
@@ -41,9 +41,6 @@ import { router as eventsRouter } from './routes/eventsRouter.js';
|
||||
import { router as eventRouter } from './routes/eventRouter.js';
|
||||
import { router as ontimeRouter } from './routes/ontimeRouter.js';
|
||||
|
||||
// Setup default port
|
||||
const port = process.env.PORT || config.server.port;
|
||||
|
||||
// Global Objects
|
||||
import { EventTimer } from './classes/EventTimer.js';
|
||||
|
||||
@@ -68,10 +65,22 @@ app.use('/event', eventRouter);
|
||||
app.use('/ontime', ontimeRouter);
|
||||
|
||||
// serve react
|
||||
app.use(express.static(path.join(__dirname, env == 'prod' ? '../' : '../../', 'client/build')));
|
||||
app.use(
|
||||
express.static(
|
||||
path.join(__dirname, env == 'prod' ? '../' : '../../', 'client/build')
|
||||
)
|
||||
);
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname, env == 'prod' ? '../' : '../../', 'client', 'build', 'index.html'));
|
||||
res.sendFile(
|
||||
path.resolve(
|
||||
__dirname,
|
||||
env == 'prod' ? '../' : '../../',
|
||||
'client',
|
||||
'build',
|
||||
'index.html'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
// Implement route for errors
|
||||
@@ -82,20 +91,31 @@ app.use((err, req, res, next) => {
|
||||
// create HTTP server
|
||||
const server = http.createServer(app);
|
||||
|
||||
// init timer
|
||||
global.timer = new EventTimer(server, config);
|
||||
global.timer.setupWithEventList(data.events);
|
||||
export const startServer = (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const serverPort = overrideConfig?.port || config.server.port;
|
||||
|
||||
// Start server
|
||||
server.listen(port, '0.0.0.0', () =>
|
||||
console.log(`HTTP Server is listening on port ${port}`)
|
||||
);
|
||||
// Start server
|
||||
server.listen(serverPort, '0.0.0.0', () =>
|
||||
console.log(`HTTP Server is listening on port ${serverPort}`)
|
||||
);
|
||||
|
||||
// init timer
|
||||
global.timer = new EventTimer(server, config);
|
||||
global.timer.setupWithEventList(data.events);
|
||||
};
|
||||
|
||||
// Start OSC server
|
||||
import { initiateOSC } from './controllers/OscController.js';
|
||||
|
||||
initiateOSC(config.osc);
|
||||
export const startOSCServer = (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const oscInPort = overrideConfig?.port || config.osc.port;
|
||||
initiateOSC(config.osc);
|
||||
};
|
||||
|
||||
export function init() {
|
||||
console.log('init');
|
||||
}
|
||||
export const startOSCClient = (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const oscOutPort = overrideConfig?.port || config.osc.portOut;
|
||||
console.log('initialise OSC Client at port: ', oscOutPort);
|
||||
};
|
||||
|
||||
@@ -11,5 +11,6 @@ export const config = {
|
||||
},
|
||||
osc: {
|
||||
port: 8888,
|
||||
portOut: 8889,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user