mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
refactor: prevent instantiating unavailable services
This commit is contained in:
committed by
Carlos Valente
parent
466360f9d1
commit
5032cbf65a
+16
-11
@@ -10,7 +10,7 @@ import { extname } from 'node:path';
|
|||||||
|
|
||||||
// import utils
|
// import utils
|
||||||
import { publicDir, srcDir, srcFiles } from './setup/index.js';
|
import { publicDir, srcDir, srcFiles } from './setup/index.js';
|
||||||
import { environment, isProduction, updateRouterPrefix } from './externals.js';
|
import { environment, isOntimeCloud, isProduction, updateRouterPrefix } from './externals.js';
|
||||||
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
||||||
import { consoleSuccess, consoleHighlight, consoleError } from './utils/console.js';
|
import { consoleSuccess, consoleHighlight, consoleError } from './utils/console.js';
|
||||||
|
|
||||||
@@ -249,16 +249,6 @@ export const startIntegrations = async () => {
|
|||||||
// if a config is not provided, we use the persisted one
|
// if a config is not provided, we use the persisted one
|
||||||
const { osc, http } = getDataProvider().getData();
|
const { osc, http } = getDataProvider().getData();
|
||||||
|
|
||||||
if (osc) {
|
|
||||||
logger.info(LogOrigin.Tx, 'Initialising OSC Integration...');
|
|
||||||
try {
|
|
||||||
oscIntegration.init(osc);
|
|
||||||
integrationService.register(oscIntegration);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(LogOrigin.Tx, 'OSC Integration initialisation failed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (http) {
|
if (http) {
|
||||||
logger.info(LogOrigin.Tx, 'Initialising HTTP Integration...');
|
logger.info(LogOrigin.Tx, 'Initialising HTTP Integration...');
|
||||||
try {
|
try {
|
||||||
@@ -268,6 +258,21 @@ export const startIntegrations = async () => {
|
|||||||
logger.error(LogOrigin.Tx, `HTTP Integration initialisation failed: ${error}`);
|
logger.error(LogOrigin.Tx, `HTTP Integration initialisation failed: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOntimeCloud) {
|
||||||
|
logger.info(LogOrigin.Tx, 'Skipping OSC in Cloud environment...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (osc) {
|
||||||
|
logger.info(LogOrigin.Tx, 'Initialising OSC Integration...');
|
||||||
|
try {
|
||||||
|
oscIntegration.init(osc);
|
||||||
|
integrationService.register(oscIntegration);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(LogOrigin.Tx, 'OSC Integration initialisation failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const isTest = Boolean(process.env.IS_TEST);
|
|||||||
export const environment = isTest ? 'test' : env;
|
export const environment = isTest ? 'test' : env;
|
||||||
export const isDocker = env === 'docker';
|
export const isDocker = env === 'docker';
|
||||||
export const isProduction = isDocker || (env === 'production' && !isTest);
|
export const isProduction = isDocker || (env === 'production' && !isTest);
|
||||||
|
export const isOntimeCloud = Boolean(process.env.IS_CLOUD);
|
||||||
/**
|
/**
|
||||||
* Updates the router prefix in the index.html file
|
* Updates the router prefix in the index.html file
|
||||||
* This is only needed in the cloud environment where the client is not at the root segment
|
* This is only needed in the cloud environment where the client is not at the root segment
|
||||||
|
|||||||
Reference in New Issue
Block a user