mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-29 10:59:07 +00:00
cleanup
This commit is contained in:
+2
-2
@@ -181,14 +181,14 @@ app.whenReady().then(() => {
|
|||||||
// Define context menu
|
// Define context menu
|
||||||
const trayMenuTemplate = [
|
const trayMenuTemplate = [
|
||||||
{
|
{
|
||||||
label: 'Show App',
|
label: 'Show App (Alt + 1)',
|
||||||
click: () => {
|
click: () => {
|
||||||
win.show();
|
win.show();
|
||||||
win.focus();
|
win.focus();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Close',
|
label: 'Shutdown',
|
||||||
click: () => {
|
click: () => {
|
||||||
win.destroy();
|
win.destroy();
|
||||||
app.quit();
|
app.quit();
|
||||||
|
|||||||
+4
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ontime",
|
"name": "ontime",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"author": "Carlos Valente",
|
"author": "Carlos Valente",
|
||||||
"description": "Time keeping for live events",
|
"description": "Time keeping for live events",
|
||||||
"repository": "https://github.com/cpvalente/ontime",
|
"repository": "https://github.com/cpvalente/ontime",
|
||||||
@@ -47,6 +47,9 @@
|
|||||||
},
|
},
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"artifactName": "ontime-win64.exe",
|
"artifactName": "ontime-win64.exe",
|
||||||
|
"oneClick": false,
|
||||||
|
"allowToChangeInstallationDirectory": true,
|
||||||
|
"allowElevation": false,
|
||||||
"createDesktopShortcut": true,
|
"createDesktopShortcut": true,
|
||||||
"createStartMenuShortcut": true,
|
"createStartMenuShortcut": true,
|
||||||
"deleteAppDataOnUninstall": true,
|
"deleteAppDataOnUninstall": true,
|
||||||
|
|||||||
+64
-8
@@ -16,7 +16,7 @@ const __dirname = path.dirname(__filename);
|
|||||||
|
|
||||||
const env = process.env.NODE_ENV || 'prod';
|
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);
|
const adapter = new JSONFile(file);
|
||||||
export const db = new Low(adapter);
|
export const db = new Low(adapter);
|
||||||
|
|
||||||
@@ -117,31 +117,87 @@ export const startServer = (overrideConfig = null) => {
|
|||||||
return returnMessage;
|
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
|
// Start OSC server
|
||||||
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
||||||
|
|
||||||
export const startOSCServer = (overrideConfig = null) => {
|
export const startOSCServer = async (overrideConfig = null) => {
|
||||||
// Setup default port
|
// Setup default port
|
||||||
const oscInPort = overrideConfig?.port || config.osc.port;
|
const oscSettings = {
|
||||||
initiateOSC(config.osc);
|
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
|
// Setup default port
|
||||||
const oscOutPort = overrideConfig?.port || config.osc.portOut;
|
const port = overrideConfig?.port || oscOutPort;
|
||||||
console.log('initialise OSC Client at 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');
|
console.log('Node service shutdown');
|
||||||
|
|
||||||
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
user.event('NODE', 'shutdown', 'requesting node shutfown').send();
|
||||||
|
|
||||||
// shutdown express server
|
// shutdown express server
|
||||||
server.close();
|
server.close();
|
||||||
|
|
||||||
// shutdown OSC Server
|
// shutdown OSC Server
|
||||||
shutdownOSCServer();
|
shutdownOSCServer();
|
||||||
|
|
||||||
// shutdown OSC Client
|
// shutdown OSC Client
|
||||||
|
oscClient.close();
|
||||||
|
|
||||||
// shutdown timer
|
// shutdown timer
|
||||||
global.timer.shutdown();
|
global.timer.shutdown();
|
||||||
|
|||||||
Reference in New Issue
Block a user