mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 23:19:09 +00:00
catch error from HTTP integration emit
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
//TODO: cleanup stuff left over from OSC copy
|
//TODO: cleanup stuff left over from OSC copy
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
import { HTTPSettings, Subscription } from 'ontime-types';
|
import { HTTPSettings, LogOrigin, Subscription } from 'ontime-types';
|
||||||
|
|
||||||
import IIntegration, { TimerLifeCycleKey } from './IIntegration.js';
|
import IIntegration, { TimerLifeCycleKey } from './IIntegration.js';
|
||||||
import { parseTemplateNested } from './integrationUtils.js';
|
import { parseTemplateNested } from './integrationUtils.js';
|
||||||
import { isObject } from '../../utils/varUtils.js';
|
import { isObject } from '../../utils/varUtils.js';
|
||||||
import { dbModel } from '../../models/dataModel.js';
|
import { dbModel } from '../../models/dataModel.js';
|
||||||
import { validateHttpObject } from '../../utils/parserFunctions.js';
|
import { validateHttpObject } from '../../utils/parserFunctions.js';
|
||||||
|
import { logger } from '../../classes/Logger.js';
|
||||||
|
|
||||||
type Action = TimerLifeCycleKey | string;
|
type Action = TimerLifeCycleKey | string;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ export class HttpIntegration implements IIntegration {
|
|||||||
// this.httpClient?.close();
|
// this.httpClient?.close();
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `HTTP integration client}`,
|
message: `HTTP integration client`,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
@@ -79,19 +80,25 @@ export class HttpIntegration implements IIntegration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit(path: string) {
|
emit(path: string) {
|
||||||
http.get(path, (res) => {
|
http
|
||||||
if (res.statusCode < 300) {
|
.get(path, (res) => {
|
||||||
return {
|
if (res.statusCode < 300) {
|
||||||
success: true,
|
res.resume();
|
||||||
message: 'HTTP Message sent',
|
return {
|
||||||
};
|
success: true,
|
||||||
} else {
|
message: 'HTTP Message sent',
|
||||||
return {
|
};
|
||||||
success: false,
|
} else {
|
||||||
message: `Error sending message responds: ${res.statusCode}`,
|
res.resume();
|
||||||
};
|
return {
|
||||||
}
|
success: false,
|
||||||
});
|
message: `Error sending message responds: ${res.statusCode}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('error', (err) => {
|
||||||
|
logger.error(LogOrigin.Tx, `HTTP integration: ${err}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdown() {
|
shutdown() {
|
||||||
|
|||||||
Reference in New Issue
Block a user