Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into superfly-elgato
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Oct 10, 2018
2 parents d3feed8 + 7b7b00b commit b553961
Show file tree
Hide file tree
Showing 11 changed files with 768 additions and 747 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Change Log

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.3.0"></a>
# [0.3.0](https://github.com/nrkno/tv-automation-casparcg-launcher/compare/v0.2.0...v0.3.0) (2018-10-10)


### Bug Fixes

* auto scroll in newer electron ([c42aa0f](https://github.com/nrkno/tv-automation-casparcg-launcher/commit/c42aa0f))
* guard against sending ipc messages while shutting down ([35f9854](https://github.com/nrkno/tv-automation-casparcg-launcher/commit/35f9854))


### Features

* Improve casparcg timeouts. Detect and ignore system clock changes ([7e80ab6](https://github.com/nrkno/tv-automation-casparcg-launcher/commit/7e80ab6))
* Improve logging to file ([dbe30bd](https://github.com/nrkno/tv-automation-casparcg-launcher/commit/dbe30bd))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Option to pass through command line options to each executable
* Basic http api to stop/start/restart each process remotely
* Auto restart each process upon crashing or exiting
* Serve folders over http (eg templates, media)

### Screenshots

Expand All @@ -28,7 +29,6 @@ yarn run dev
# build electron application for production
yarn run build


# lint all JS/Vue component files in `src/`
yarn run lint

Expand Down
7 changes: 7 additions & 0 deletions casparcg_launcher_autorestart.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@Echo off

:Start

casparcg-launcher.exe

if %ERRORLEVEL% NEQ 0 goto :Start
Binary file modified doc/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "casparcg-launcher",
"version": "0.2.0-elgato",
"version": "0.3.0-elgato",
"author": "Julian Waller <[email protected]>",
"description": "Simple launcher for CasparCG",
"license": "MIT",
Expand Down Expand Up @@ -64,6 +64,7 @@
"jquery": "^3.3.1",
"respawn": "^2.5.0",
"serve-index": "^1.7.2",
"smoothscroll-polyfill": "^0.4.3",
"string-argv": "^0.0.2",
"vue": "^2.3.3",
"vue-chat-scroll": "^1.2.1",
Expand Down
14 changes: 10 additions & 4 deletions src/main/casparcg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import log from 'electron-log'

const startupDelay = 5000
const pingInterval = 5000
const pingTimeout = 8000
const pingTimeout = 12000 // 2 pings

export class CasparCGHealthMonitor {
init (procMon) {
Expand Down Expand Up @@ -32,8 +32,8 @@ export class CasparCGHealthMonitor {
this.lastReceived = Date.now()
})
this.client.on('error', e => {
log.error('[' + this.procMon.id + '] ' + e)
if (this.interval && this.procMon.running()) {
log.error('[' + this.procMon.id + '] ' + e)
this.procMon.stop(() => this.procMon.start())
}
})
Expand All @@ -48,13 +48,19 @@ export class CasparCGHealthMonitor {
log.info('[' + this.procMon.id + '] ping timer starting')

this.lastReceived = Date.now()
this.lastSent = Date.now()

this.interval = setInterval(() => {
if (Date.now() - this.lastReceived > pingTimeout) {
log.warn('[' + this.procMon.id + '] ping timeout')
if (Date.now() - this.lastSent > pingTimeout) {
log.warn('[' + this.procMon.id + '] time skipped by ' + (Date.now() - this.lastSent))
} else if (this.lastSent - this.lastReceived > pingTimeout) {
log.warn('[' + this.procMon.id + '] ping timeout after ' + (this.lastSent - this.lastReceived))
this.procMon.pipeLog('log', '[error] ping timeout after ' + (this.lastSent - this.lastReceived))
this.procMon.stop(() => this.procMon.start())
return
}

this.lastSent = Date.now()
this.client.write('PING\r\n')
}, pingInterval)
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

log.transports.file.level = 'info'

process.on('uncaughtException', function (err) {
log.error('uncaught exception: ', err.stack)
process.exit(1)
})

const config = new Conf({
cwd: process.env.PORTABLE_EXECUTABLE_DIR,
configName: 'casparcg-launcher.config'
Expand Down Expand Up @@ -50,10 +57,13 @@ function createWindow () {
if (choice === 1) {
e.preventDefault()
}

log.info('shutting down')
})

mainWindow.on('closed', () => {
mainWindow = null
log.info('closed')
})

mainWindow.webContents.once('did-finish-load', () => {
Expand Down Expand Up @@ -89,7 +99,9 @@ class IpcWrapper {
}

send (event, msg) {
this.ipcOut.send(event, msg)
if (!this.ipcOut.isDestroyed()) {
this.ipcOut.send(event, msg)
}
}
}

Expand Down
21 changes: 10 additions & 11 deletions src/main/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ProcessMonitor {
}

this.ipcWrapper.on(this.id + '.control', (sender, cmd) => {
log.info('Got process control command for ' + this.id + ': ' + cmd)
log.info('[' + this.id + '] Got process control command : ' + cmd)
if (cmd === 'stop') {
this.stop()
} else if (cmd === 'start') {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class ProcessMonitor {
procPath = path.join(basePath, procPath)
}

log.info(`Booting Process ${procPath}`)
log.info(`[${this.id}] Booting Process ${procPath}`)

let fileExists
try {
Expand All @@ -62,7 +62,7 @@ export class ProcessMonitor {
fileExists = false
}
if (!fileExists) {
log.info('Executable does not exist: ' + procPath)
log.info('[' + this.id + '] Executable does not exist: ' + procPath)
this.pipeLog('event', '== Executable does not exist ==')
this.pipeStatus('failed')
return
Expand All @@ -80,6 +80,7 @@ export class ProcessMonitor {
this.healthMon.start()
}

log.info('[' + this.id + '] ' + this.exeName + ' start')
this.pipeLog('event', '== Process has started ==')
this.pipeStatus('running')
})
Expand All @@ -88,13 +89,11 @@ export class ProcessMonitor {
lines.forEach(l => this.pipeLog('log', l))
})
this.process.on('stderr', (data) => {
log.info(this.exeName + ' stderr')

const lines = data.toString().trim().split('\r\n')
lines.forEach(l => this.pipeLog('error', l))
lines.forEach(l => this.pipeLog('log', l))
})
this.process.on('stop', () => {
log.info(this.exeName + ' stop')
log.info('[' + this.id + '] ' + this.exeName + ' stop')
if (this.healthMon) {
this.healthMon.stop()
}
Expand All @@ -103,20 +102,20 @@ export class ProcessMonitor {
this.pipeStatus('stopped')
})
this.process.on('crash', () => {
log.info(this.exeName + ' crash')
log.info('[' + this.id + '] ' + this.exeName + ' crash')
this.pipeLog('event', '== Process has crashed ==')
})
this.process.on('sleep', () => {
log.info(this.exeName + ' sleep')
log.info('[' + this.id + '] ' + this.exeName + ' sleep')
this.pipeLog('event', '== Process is sleeping ==')
})
this.process.on('spawn', (process) => {
log.info(this.exeName + ' spawn ' + process.pid)
log.info('[' + this.id + '] ' + this.exeName + ' spawn ' + process.pid)

this.pipeLog('event', '== Process is starting ==')
})
this.process.on('exit', (code, signal) => {
log.info(this.exeName + ' exit ' + code + ' ' + signal)
log.info('[' + this.id + '] ' + this.exeName + ' exit ' + code + ' ' + signal)

this.pipeLog('event', '== Process has exited with code ' + code + ' ==')
})
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
</b-form-group>

<b-form-group id="httpApiEnableGroup"
label="Enable HTTP Api:"
label="Enable HTTP Server:"
label-for="httpApiEnableInput">
<b-form-checkbox id="httpApiEnableInput"
v-model="config.api.enable">
</b-form-checkbox>
</b-form-group>

<b-form-group id="httpApiPortGroup"
label="HTTP Api Port:"
label="HTTP Server Port:"
label-for="httpApiPortInput">
<b-form-input id="httpApiPortInput"
type="number"
Expand All @@ -72,7 +72,7 @@
</b-form-group>

<b-form-group id="httpApiProcessControlGroup"
label="Enable HTTP Process control:"
label="Enable HTTP Process control API:"
label-for="httpApiProcessControlInput">
<b-form-checkbox id="httpApiProcessControlInput"
v-model="config.api.processControl">
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import App from './App'
import router from './router'
import store from './store'

import smoothscroll from 'smoothscroll-polyfill'
smoothscroll.polyfill()

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.config.productionTip = false

Expand Down
Loading

0 comments on commit b553961

Please sign in to comment.