mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
cleanup
This commit is contained in:
+2
-2
@@ -181,14 +181,14 @@ app.whenReady().then(() => {
|
||||
// Define context menu
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: 'Show App',
|
||||
label: 'Show App (Alt + 1)',
|
||||
click: () => {
|
||||
win.show();
|
||||
win.focus();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
label: 'Shutdown',
|
||||
click: () => {
|
||||
win.destroy();
|
||||
app.quit();
|
||||
|
||||
+4
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ontime",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"author": "Carlos Valente",
|
||||
"description": "Time keeping for live events",
|
||||
"repository": "https://github.com/cpvalente/ontime",
|
||||
@@ -47,6 +47,9 @@
|
||||
},
|
||||
"nsis": {
|
||||
"artifactName": "ontime-win64.exe",
|
||||
"oneClick": false,
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"allowElevation": false,
|
||||
"createDesktopShortcut": true,
|
||||
"createStartMenuShortcut": true,
|
||||
"deleteAppDataOnUninstall": true,
|
||||
|
||||
+64
-8
@@ -16,7 +16,7 @@ const __dirname = path.dirname(__filename);
|
||||
|
||||
const env = process.env.NODE_ENV || 'prod';
|
||||
|
||||
const file = path.join(__dirname, '../data/', config.database.filename);
|
||||
const file = path.join(__dirname, 'data/', config.database.filename);
|
||||
const adapter = new JSONFile(file);
|
||||
export const db = new Low(adapter);
|
||||
|
||||
@@ -117,31 +117,87 @@ export const startServer = (overrideConfig = null) => {
|
||||
return returnMessage;
|
||||
};
|
||||
|
||||
/*************** START SERVICES ***************/
|
||||
/* Override config
|
||||
* ----------------
|
||||
*
|
||||
* Configuration of services comes from app general config
|
||||
* It can be overriden here by the settings in the db
|
||||
* It can also be overriden on call
|
||||
*
|
||||
*/
|
||||
|
||||
const s = data.settings;
|
||||
|
||||
const oscIP = s.oscOutIP || config.osc.ipOut;
|
||||
const oscOutPort = s.oscOutPort || config.osc.portOut;
|
||||
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 = (overrideConfig = null) => {
|
||||
export const startOSCServer = async (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const oscInPort = overrideConfig?.port || config.osc.port;
|
||||
initiateOSC(config.osc);
|
||||
const oscSettings = {
|
||||
port: overrideConfig?.port || oscInPort,
|
||||
ipOut: oscIP,
|
||||
portOut: oscOutPort,
|
||||
};
|
||||
|
||||
// Start OSC Server
|
||||
initiateOSC(oscSettings);
|
||||
};
|
||||
|
||||
export const startOSCClient = (overrideConfig = null) => {
|
||||
// Start OSC Client
|
||||
let oscClient = null;
|
||||
|
||||
export const startOSCClient = async (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
const oscOutPort = overrideConfig?.port || config.osc.portOut;
|
||||
console.log('initialise OSC Client at port: ', oscOutPort);
|
||||
const port = overrideConfig?.port || oscOutPort;
|
||||
console.log('initialise OSC Client on port: ', port);
|
||||
|
||||
oscClient = new Client(oscIP, oscOutPort);
|
||||
};
|
||||
|
||||
export const shutdown = () => {
|
||||
// create HTTP server
|
||||
const server = http.createServer(app);
|
||||
|
||||
export const startServer = async (overrideConfig = null) => {
|
||||
// Setup default port
|
||||
// const port = overrideConfig?.port || serverPort;
|
||||
|
||||
/* Note: Port is hardcoded
|
||||
* need to find a good solution for sharing
|
||||
* the dynamic info with the frontend
|
||||
*/
|
||||
const port = 4001;
|
||||
|
||||
// Start server
|
||||
const returnMessage = `HTTP Server is listening on port ${port}`;
|
||||
server.listen(port, '0.0.0.0', () => console.log(returnMessage));
|
||||
|
||||
// init timer
|
||||
global.timer = new EventTimer(server, oscClient, config);
|
||||
global.timer.setupWithEventList(data.events);
|
||||
|
||||
return returnMessage;
|
||||
};
|
||||
|
||||
export const shutdown = async () => {
|
||||
console.log('Node service shutdown');
|
||||
|
||||
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
||||
|
||||
// shutdown express server
|
||||
server.close();
|
||||
|
||||
// shutdown OSC Server
|
||||
shutdownOSCServer();
|
||||
|
||||
// shutdown OSC Client
|
||||
oscClient.close();
|
||||
|
||||
// shutdown timer
|
||||
global.timer.shutdown();
|
||||
|
||||
Reference in New Issue
Block a user