Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: casparcg restart action always responds 'OK' SOFIE-2588 #295

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,7 @@ export class CasparCGDevice extends DeviceWithState<State, DeviceOptionsCasparCG
case CasparCGActions.ClearAllChannels:
return this.clearAllChannels()
case CasparCGActions.RestartServer:
await this.restartCasparCG()
return {
result: ActionExecutionResultCode.Ok,
}
return this.restartCasparCG()
default:
return {
result: ActionExecutionResultCode.Error,
Expand Down Expand Up @@ -703,27 +700,34 @@ export class CasparCGDevice extends DeviceWithState<State, DeviceOptionsCasparCG
}
}

return new Promise<ActionExecutionResult>((resolve) => {
const url = `http://${this.initOptions?.launcherHost}:${this.initOptions?.launcherPort}/processes/${this.initOptions?.launcherProcess}/restart`
got
.post(url)
.then((response) => {
if (response.statusCode === 200) {
resolve({ result: ActionExecutionResultCode.Ok })
} else {
resolve({
result: ActionExecutionResultCode.Error,
response: t('Bad reply: [{{statusCode}}] {{body}}', {
statusCode: response.statusCode,
body: response.body,
}),
})
const url = `http://${this.initOptions?.launcherHost}:${this.initOptions?.launcherPort}/processes/${this.initOptions?.launcherProcess}/restart`
return got
.post(url, {
timeout: {
request: 5000, // Arbitary, long enough for realistic scenarios
},
})
.then((response) => {
if (response.statusCode === 200) {
return { result: ActionExecutionResultCode.Ok }
} else {
return {
result: ActionExecutionResultCode.Error,
response: t('Bad reply: [{{statusCode}}] {{body}}', {
statusCode: response.statusCode,
body: response.body,
}),
}
})
.catch((error) => {
resolve({ result: ActionExecutionResultCode.Error, response: error })
})
})
}
})
.catch((error) => {
return {
result: ActionExecutionResultCode.Error,
response: t('{{message}}', {
message: error.toString(),
}),
}
})
}
getStatus(): DeviceStatus {
let statusCode = StatusCode.GOOD
Expand Down
Loading