Cleanup. Fixed bug in casparcg client. Replaced browserify and babelify with asbundle. Updated all packages.
This commit is contained in:
parent
71ac85ab7f
commit
653ac2dba0
13 changed files with 2684 additions and 4491 deletions
|
@ -13,6 +13,7 @@ WORKDIR $HOME
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc g++ python && \
|
RUN apk add --no-cache make gcc g++ python && \
|
||||||
npm install && \
|
npm install && \
|
||||||
|
apk del make gcc g++ python && \
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import Settings from '../settings/model'
|
import Settings from '../settings/model'
|
||||||
import { address } from 'ip'
|
|
||||||
import { CasparCG, AMCP } from 'casparcg-connection'
|
import { CasparCG, AMCP } from 'casparcg-connection'
|
||||||
|
|
||||||
const timeoutDuration = 60000
|
const timeoutDuration = 5000
|
||||||
|
|
||||||
let io
|
let io
|
||||||
let logger
|
let logger
|
||||||
|
@ -10,7 +9,6 @@ let logger
|
||||||
let connection
|
let connection
|
||||||
let casparIsPlaying
|
let casparIsPlaying
|
||||||
let casparIsConnected
|
let casparIsConnected
|
||||||
let checkTimeout
|
|
||||||
let currentHost
|
let currentHost
|
||||||
|
|
||||||
export async function initialise(log, socket) {
|
export async function initialise(log, socket) {
|
||||||
|
@ -36,27 +34,23 @@ export async function connect() {
|
||||||
queueMode: 2,
|
queueMode: 2,
|
||||||
autoReconnectInterval: timeoutDuration,
|
autoReconnectInterval: timeoutDuration,
|
||||||
onError: err => {
|
onError: err => {
|
||||||
logger.error('CasparCG: Error', err.message)
|
logger.error(err, 'CasparCG: Error')
|
||||||
},
|
},
|
||||||
onConnectionStatus: data => {
|
onConnectionStatus: data => {
|
||||||
casparIsConnected = data.connected
|
casparIsConnected = data.connected
|
||||||
|
|
||||||
if (!data.connected) {
|
if (!casparIsConnected) {
|
||||||
casparIsPlaying = false
|
logger.warn(`CasparCG: connection down, retrying in ${timeoutDuration / 1000} seconds`)
|
||||||
logger.warn('CasparCG: connection closed, retrying in 60 seconds', connection.connected)
|
|
||||||
io.emit('casparcg.status', currentStatus())
|
io.emit('casparcg.status', currentStatus())
|
||||||
if (checkTimeout) clearInterval(checkTimeout)
|
|
||||||
checkTimeout = null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onConnected: async connected => {
|
onConnected: async connected => {
|
||||||
logger.info('CasparCG: connected', connected)
|
logger.info('CasparCG: connected', connected)
|
||||||
io.emit('casparcg.status', currentStatus())
|
if (!casparIsPlaying) {
|
||||||
checkClientPlaying(false, true)
|
startPlaying().then()
|
||||||
|
} else {
|
||||||
// Run our check on hourly interval
|
logger.warn('CasparCG: Stopped from starting play again.')
|
||||||
if (checkTimeout) clearInterval(checkTimeout)
|
}
|
||||||
checkTimeout = setInterval(() => checkClientPlaying(), timeoutDuration * 60)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -69,52 +63,40 @@ export function currentStatus(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkClientPlaying(starting = false, first = false) {
|
export async function startPlaying() {
|
||||||
let ip
|
let ip = 'localhost'
|
||||||
if (currentHost === 'localhost' || currentHost === '127.0.0.1') {
|
|
||||||
ip = 'localhost'
|
|
||||||
} else {
|
|
||||||
ip = address()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we lost connection while attempting to start playing
|
// Check if we lost connection while attempting to start playing
|
||||||
if (!connection.connected) {
|
if (!connection.connected) {
|
||||||
logger.error('CasparCG: Attempted to play but connection was lost')
|
logger.error('CasparCG: Attempted to play but connection was lost')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let success = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if we're already playing
|
// Send a play command
|
||||||
let output = await connection.info(1, 100)
|
let command = `PLAY 1-100 [HTML] "http://${ip}:3000/client.html" CUT 1 LINEAR RIGHT`
|
||||||
|
logger.info(`CasparCG Command: ${command}`)
|
||||||
if (output.response.data.status !== 'playing') {
|
await connection.do(new AMCP.CustomCommand(command))
|
||||||
casparIsPlaying = false
|
success = true
|
||||||
|
} catch (e) {
|
||||||
if (starting) {
|
// Weird error where it throws an error despite a successful play command on reconnect
|
||||||
// We are not playing, check to see if we've already attempted
|
if (e && e.responseProtocol && e.responseProtocol.code >= 200 && e.responseProtocol.code < 300) {
|
||||||
// to issue a play command and delay trying for a minute
|
success = true
|
||||||
await new Promise(res => {
|
} else {
|
||||||
logger.warn('CasparCG: Play did not start playing, retrying in 60 seconds')
|
logger.error(e, 'CasparCG: Error starting play on client')
|
||||||
setTimeout(res, timeoutDuration)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a play command and retry checking again
|
|
||||||
logger.info(`CasparCG: Sending play command for ${ip}:3000`)
|
|
||||||
await connection.do(new AMCP.CustomCommand(`PLAY 1-100 [HTML] "http://${ip}:3000/client.html" CUT 1 LINEAR RIGHT`))
|
|
||||||
return checkClientPlaying(true)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
casparIsPlaying = true
|
casparIsPlaying = true
|
||||||
|
|
||||||
// We are playing, notify all clients
|
// We are playing, notify all clients
|
||||||
io.emit('casparcg.status', currentStatus())
|
io.emit('casparcg.status', currentStatus())
|
||||||
if (starting || first) {
|
logger.info('CasparCG: client is up and playing')
|
||||||
logger.info('CasparCG: client is up and playing')
|
} else {
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Unknown error occured
|
// Unknown error occured
|
||||||
casparIsPlaying = true
|
casparIsPlaying = false
|
||||||
logger.error(e, 'CasparCG: Error starting play on client')
|
|
||||||
io.emit('casparcg.status', currentStatus(e))
|
io.emit('casparcg.status', currentStatus(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
app/client.js
Normal file
8
app/client.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,4 @@
|
||||||
var io = require('socket.io-client')
|
var io = require('./client')
|
||||||
|
|
||||||
var socket = io()
|
var socket = io()
|
||||||
|
|
||||||
module.exports = socket
|
module.exports = socket
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
* {
|
* {
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
box-sizing:border-box; /* This sets all elements to be the actual set dimensions, disregarding padding and borders */
|
box-sizing:border-box; /* This sets all elements to be the actual set dimensions, disregarding padding and borders */
|
||||||
/* -webkit-backface-visibility: hidden; /* Hide the backface of elements - useful for 3d effects */
|
/* -webkit-backface-visibility: hidden; */ /* Hide the backface of elements - useful for 3d effects */
|
||||||
-webkit-transition: translate3d(0,0,0); /* Turns on hardware acceleration - not known to be of benefit in CCG, but won't hurt */
|
-webkit-transition: translate3d(0,0,0); /* Turns on hardware acceleration - not known to be of benefit in CCG, but won't hurt */
|
||||||
}
|
}
|
||||||
html, body {
|
html, body {
|
||||||
|
@ -25,7 +25,7 @@ body {
|
||||||
body {
|
body {
|
||||||
font-family: Arial;
|
font-family: Arial;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
text-shadow: 0px 0px 0px #000000;
|
/* text-shadow: 0px 0px 0px #000000; */
|
||||||
font-size: 22pt;
|
font-size: 22pt;
|
||||||
}
|
}
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -294,6 +294,14 @@ $header-color = #777777;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea#graphic-html {
|
||||||
|
min-height: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea#graphic-css {
|
||||||
|
min-height: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
input[type=submit] {
|
||||||
margin-top: 0.6em;
|
margin-top: 0.6em;
|
||||||
border: none;
|
border: none;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"host": "0.0.0.0"
|
"host": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"bunyan": {
|
"bunyan": {
|
||||||
"name": "keywe",
|
"name": "caspar",
|
||||||
"streams": [{
|
"streams": [{
|
||||||
"stream": "process.stdout",
|
"stream": "process.stdout",
|
||||||
"level": "debug"
|
"level": "debug"
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"ignore": ["app/*", "public/*"]
|
|
||||||
}
|
|
7004
package-lock.json
generated
7004
package-lock.json
generated
File diff suppressed because it is too large
Load diff
50
package.json
50
package.json
|
@ -4,29 +4,19 @@
|
||||||
"description": "CasparCG superimposed graphics project",
|
"description": "CasparCG superimposed graphics project",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:styl": "stylus -m app/styl/main.styl --out public",
|
"build:styl": "stylus -m app/styl/main.styl --out public && stylus -m app/styl/client.styl --out public && stylus -m app/styl/status.styl --out public",
|
||||||
"watch:styl": "stylus -w -m app/styl/main.styl --out public",
|
"watch:styl": "stylus -w -m app/styl/main.styl app/styl/client.styl app/styl/status.styl --out public",
|
||||||
"build-client:styl": "stylus -m app/styl/client.styl --out public",
|
"build:js": "asbundle app/main/index.js ../../../public/main.js && asbundle app/client/index.js public/client.js && asbundle app/status/index.js ../../public/status.js",
|
||||||
"watch-client:styl": "stylus -w -m app/styl/client.styl --out public",
|
"watch:js": "nodemon --watch app --exec \"npm run build:js\"",
|
||||||
"build-status:styl": "stylus -m app/styl/status.styl --out public",
|
"watch:server": "nodemon --watch api index.js | bunyan -o short",
|
||||||
"watch-status:styl": "stylus -w -m app/styl/status.styl --out public",
|
|
||||||
"watch:js": "watchify -t babelify app/main/index.js -o public/main.js --debug",
|
|
||||||
"build:js": "browserify app/main/index.js -o public/main.js --debug -t [ babelify ]",
|
|
||||||
"watch-client:js": "watchify -t babelify app/client/index.js -o public/client.js --debug",
|
|
||||||
"build-client:js": "browserify app/client/index.js -o public/client.js --debug -t [ babelify ]",
|
|
||||||
"watch-status:js": "watchify -t babelify app/status/index.js -o public/status.js --debug",
|
|
||||||
"build-status:js": "browserify app/status/index.js -o public/status.js --debug -t [ babelify ]",
|
|
||||||
"watch:server": "nodemon index.js",
|
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"start:win": "node index.js | bunyan",
|
"start:win": "node index.js | bunyan",
|
||||||
"dev-run": "run-p watch:js watch-client:js watch-status:js watch:server watch:styl watch-client:styl watch-status:styl",
|
"dev": "run-p watch:styl watch:js watch:server",
|
||||||
"prod-run": "npm run build:js && npm run build-client:js && npm run build-status:js && npm run build:styl && npm run build-client:styl && npm run build-status:styl && npm start",
|
"prod-run": "npm run build:js && npm run build-client:js && npm run build-status:js && npm run build:styl && npm run build-client:styl && npm run build-status:styl && npm start",
|
||||||
"build": "npm run build:js && npm run build-client:js && npm run build-status:js && npm run build:styl && npm run build-client:styl && npm run build-status:styl",
|
"build": "npm run build:js && npm run build:styl",
|
||||||
"test": "env NODE_ENV=test mocha --require babel-register --recursive --reporter dot",
|
"docker": "docker run -it --rm --name my-running-script -p 3000:3000 -v \"%cd%\":/usr/src/app -w /usr/src/app node",
|
||||||
"docker": "docker run -it --rm --name my-running-script -v \"$PWD\":/usr/src/app -w /usr/src/app node:alpine",
|
"docker:install": "npm run docker -- npm install",
|
||||||
"docker:test": "npm run docker -- npm install && npm run test",
|
"docker:dev": "npm run docker -- npm run dev"
|
||||||
"docker:dev": "npm run docker -- npm install && npm run dev-run",
|
|
||||||
"docker:run": "npm run docker -- npm install && npm run prod-run"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -48,28 +38,24 @@
|
||||||
"babel-register": "^6.26.0",
|
"babel-register": "^6.26.0",
|
||||||
"bookshelf": "^0.11.1",
|
"bookshelf": "^0.11.1",
|
||||||
"bunyan": "^1.8.12",
|
"bunyan": "^1.8.12",
|
||||||
"casparcg-connection": "4.1.0",
|
"casparcg-connection": "4.9.0",
|
||||||
"ip": "^1.1.5",
|
"ip": "^1.1.5",
|
||||||
"knex": "^0.12.9",
|
"knex": "^0.12.9",
|
||||||
"koa": "^2.4.1",
|
"koa": "^2.4.1",
|
||||||
"koa-better-serve": "^2.0.7",
|
"koa-better-serve": "^2.0.7",
|
||||||
"koa-socket": "^4.4.0",
|
"koa-socket": "^4.4.0",
|
||||||
"nconf": "^0.9.1",
|
"nconf": "^0.9.1",
|
||||||
"socket.io": "^2.0.4",
|
"socket.io": "^2.3.0",
|
||||||
"sqlite3": "^3.1.13"
|
"sqlite3": "^4.1.1",
|
||||||
|
"tslib": "^1.11.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babelify": "^8.0.0",
|
"asbundle": "^2.6.0",
|
||||||
"browserify": "^16.2.2",
|
|
||||||
"dragula": "^3.7.2",
|
"dragula": "^3.7.2",
|
||||||
"eslint": "^4.16.0",
|
|
||||||
"eslint-plugin-mocha": "^4.11.0",
|
|
||||||
"mithril": "^1.1.5",
|
"mithril": "^1.1.5",
|
||||||
"mocha": "^4.0.1",
|
|
||||||
"nodemon": "^1.12.1",
|
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"socket.io-client": "^2.0.4",
|
"nodemon": "^2.0.2",
|
||||||
"stylus": "^0.54.5",
|
"run-p": "0.0.0",
|
||||||
"watchify": "^3.9.0"
|
"stylus": "^0.54.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
/* This sets all elements to be the actual set dimensions, disregarding padding and borders */
|
/* This sets all elements to be the actual set dimensions, disregarding padding and borders */
|
||||||
/* -webkit-backface-visibility: hidden; /* Hide the backface of elements - useful for 3d effects */
|
/* -webkit-backface-visibility: hidden; */
|
||||||
|
/* Hide the backface of elements - useful for 3d effects */
|
||||||
-webkit-transition: translate3d(0, 0, 0); /* Turns on hardware acceleration - not known to be of benefit in CCG, but won't hurt */
|
-webkit-transition: translate3d(0, 0, 0); /* Turns on hardware acceleration - not known to be of benefit in CCG, but won't hurt */
|
||||||
}
|
}
|
||||||
html,
|
html,
|
||||||
|
@ -33,7 +34,7 @@ body {
|
||||||
body {
|
body {
|
||||||
font-family: Arial;
|
font-family: Arial;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
text-shadow: 0px 0px 0px #000;
|
/* text-shadow: 0px 0px 0px #000000; */
|
||||||
font-size: 22pt;
|
font-size: 22pt;
|
||||||
}
|
}
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"sources":["../app/styl/client.styl"],"names":[],"mappings":"AAAA;EACE,oBAAoB,WAApB;EACA,YAAW,WAAX;AAA4C;AAC7C;EACC,oBAAqC,qBAArC;AAA4C;;AAE9C;AAAM;EACJ,OAAM,OAAN;AAAyD;EACzD,QAAO,OAAP;AAAyD;EACzD,QAAO,EAAP;AAAyD;EACzD,SAAQ,EAAR;AAAyD;EACzD,YAAW,YAAX;AAAyD;EACzD,UAAS,OAAT;AAAyD;EACzD,wBAAuB,uBAAvB;AAAyD;;AAE3D;EACE,aAAoB,eAApB;EACA,WAAW,KAAX;EACA,OAAO,KAAP;AACA;;;;AAKF;EACE,aAAa,MAAb;EACA,aAAa,OAAb;EACA,aAAa,iBAAb;EACA,WAAW,KAAX;;AAEF;EACE,UAAU,KAAV;;AAEF;EAEE,UAAU,SAAV;;AAGF;EACE,SAAS,EAAT;EACA,YAAY,WAAZ;;AAGF;EACE,SAAS,EAAT;EACA,YAAY,WAAZ","file":"client.css"}
|
{"version":3,"sources":["../app/styl/client.styl"],"names":[],"mappings":"AAAA;EACE,oBAAoB,WAApB;EACA,YAAW,WAAX;AAA4C;AAC7C;AAAiD;EAChD,oBAAoB,qBAApB;AAA4C;;AAE9C;AAAM;EACJ,OAAM,OAAN;AAAyD;EACzD,QAAO,OAAP;AAAyD;EACzD,QAAO,EAAP;AAAyD;EACzD,SAAQ,EAAR;AAAyD;EACzD,YAAW,YAAX;AAAyD;EACzD,UAAS,OAAT;AAAyD;EACzD,wBAAuB,uBAAvB;AAAyD;;AAE3D;EACE,aAAoB,eAApB;EACA,WAAW,KAAX;EACA,OAAO,KAAP;AACA;;;;AAKF;EACE,aAAa,MAAb;EACA,aAAa,OAAb;AACA;EACA,WAAW,KAAX;;AAEF;EACE,UAAU,KAAV;;AAEF;EAEE,UAAU,SAAV;;AAGF;EACE,SAAS,EAAT;EACA,YAAY,WAAZ;;AAGF;EACE,SAAS,EAAT;EACA,YAAY,WAAZ","file":"client.css"}
|
|
@ -1,9 +0,0 @@
|
||||||
git pull
|
|
||||||
START openbrowser.bat
|
|
||||||
CALL npm install
|
|
||||||
CALL npm run build
|
|
||||||
CALL npm run start:win
|
|
||||||
echo.
|
|
||||||
echo EXITED
|
|
||||||
echo.
|
|
||||||
PAUSE
|
|
Loading…
Reference in a new issue