Commit 4c802ac7 authored by Tom JORQUERA's avatar Tom JORQUERA
Browse files

Merge branch 'issue-32' into 'master'

Issue 32

Closes #32

See merge request !28
parents 9e4c50db 7c67d9bd
Dockerfile
.dockerignore
.git
node_modules/*
tmp/
nohup.out
MODELS_PATH=./models/
YAML=/opt/models/gmm_hmm3.yaml
NB_WORKERS=2
......@@ -54,8 +54,5 @@ typings/
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
tmp/
nohup.out
FROM node:8-stretch
RUN apt-get -q update && apt-get -y -q install \
chromium \
libgconf-2-4 \
openjdk-8-jre-headless \
xvfb \
&& npm set -g progress=false \
&& rm -rf /var/lib/apt/lists/*
FROM node:8-alpine
WORKDIR /usr/src/app/hublot
COPY package.json .
RUN npm install
RUN npm run setup
COPY docker-chromium-xvfb/xvfb-chromium /usr/bin/xvfb-chromium
RUN ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome && \
ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser
RUN yarn install
COPY . /usr/src/app/hublot
RUN chmod +x start.sh
CMD ./start.sh
ENTRYPOINT ["yarn", "start"]
......@@ -3,8 +3,11 @@ const config = require('./config.json');
const runner = require('./lib/runner.js')(config.runner);
const controller = require('./lib/controller.js')('./client');
console.log('starting hublot...');
controller.loadAll('controller', 'lib', 'robot')
.then(modules => {
console.log('modules loaded... launching runner');
// Note: result can be stored in a variable to control further the browser
// e.g.: let client = runner.run(...); client.end();
runner.run(modules, config.visio.url, 'test-bot', config.client);
......@@ -12,3 +15,8 @@ controller.loadAll('controller', 'lib', 'robot')
.catch(err => {
console.error(err);
});
// Hang
(function wait() {
setTimeout(wait, 10000);
})();
#!/bin/sh
if [ -f ./tmp/webdriver_pid ]
then
echo "./tmp/webdriver_pid already exists. Is the server running?" 1>&2
else
nohup ./node_modules/.bin/selenium-standalone start &
mkdir -p ./tmp
echo $! > ./tmp/webdriver_pid
fi
#!/bin/sh
if [ -f ./tmp/webdriver_pid ]
then
kill $( cat ./tmp/webdriver_pid );
rm ./tmp/webdriver_pid
fi
......@@ -13,7 +13,7 @@ robotController = {
chatService: angular.element(document.body).injector().get('chat'),
getMyID: () => {
getMyId: () => {
return easyrtc.myEasyrtcid;
},
......
......@@ -27,23 +27,34 @@ robotLib.reco = function (config) {
return {
start: confid => {
if (!connected) {
console.error('Online reco: not connected but trying to send start to conf %s', confid);
return false;
}
const xhttp = new XMLHttpRequest();
xhttp.open('GET', 'http://' + config.reco.host + ':' + config.reco.port + '/stream?action=START&id=' + confid, false);
xhttp.send();
return true;
},
stop: confid => {
if (!connected) {
console.error('Online reco: not connected but trying to send stop to conf %s', confid);
return false;
}
const xhttp = new XMLHttpRequest();
xhttp.open('GET', 'http://' + config.reco.host + ':' + config.reco.port + '/stream?action=STOP&id=' + confid, false);
xhttp.send();
return true;
},
send: content => {
if (connected) {
recoStompClient.send('/app/chat', {}, JSON.stringify(content));
} else {
if (!connected) {
console.error('Online reco: not connected but trying to send %j', content);
return false;
}
recoStompClient.send('/app/chat', {}, JSON.stringify(content));
return true;
},
getOnlineReco: confId => {
......
......@@ -101,7 +101,14 @@ robot = {
robot.stopRecordParticipant(data.easyrtcid);
};
robotLib.reco.start(room);
function recoStartRetry() {
if (!robotLib.reco.start(room)) {
setTimeout(recoStartRetry, 8000);
}
}
// If start fails, schedule retry at fixed interval until success
recoStartRetry();
setInterval(
() => robotLib.reco.getOnlineReco(room)
.then(robot.processReco)
......@@ -117,3 +124,5 @@ robot = {
}
}
};
console.log('robot initialized');
......@@ -4,16 +4,18 @@
},
"runner": {
"driver" : {
"host": "selenium",
"port": 4444,
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args" : [
"--disable-web-security",
"--user-data-dir=./tmp/chromium",
"--allow-running-insecure-content",
"--user-data-dir=./tmp/chromium",
"--allow-running-insecure-content",
"--use-fake-device-for-media-stream",
"--use-file-for-fake-audio-capture=./media/silence.wav",
"--use-file-for-fake-video-capture=./media/logo.y4m",
"--use-file-for-fake-audio-capture=/opt/media/silence.wav",
"--use-file-for-fake-video-capture=/opt/media/logo.y4m",
"--use-fake-ui-for-media-stream"
]
}
......@@ -23,15 +25,15 @@
"client": {
"name": "hublot",
"avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABECAYAAAAm2qMBAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4QYNDTU7dwT3OwAABUtJREFUeNrtnF1oHFUUx38zjUlabWKtELU3WLQPFrSOgopaRawmIZdqLVTtQ1R8sVqsH9SvQptKBaWF6oMiLYhUKiLYtMVOGqu0Kgnq260txQejEIZU0BRrqsaQZH2YO3Hczu7Ofszs1/xhyWaZPXvnN+fOPffcc8cgBlm2g5LCe38xcBtgAdcAi4HLgUuAi4BG/bVJ4BxwBhgFfgZ+ABQwpKQYT7cdpYyY4KwCHgDuB1pL9BNjwEFgv5LiUNTQogTVCTwF3Ec86gPeVlIciwKaEQGgp4HtQDPl0TiwUUmxu5TAjBJ2r2eAt6gcpYAnlRS7LNsBKAqYUSwky3Y6gAPAXCpTfwArlRRfF+NdRhGA5gH7gC6qQ33AWj2a5g3MKBDSzcB32r2NKgGV0q8blBTf5/tlswBImzQkqgiS11YTOG7ZznrvnErqUT5I+4DV1IY+UFI8Gva+ZeQBaUhH1LWkz5UUHWFgGSEhfQPcUmVdLayOKilW5IJlhIA0AHTUKCRPnygp1hTjUTuB56gPbVZSvFaIR3UCA9SXblVSfBsKlB4ym4AJ6lNGUEB6XhylD/iiTiGlgMNBN3UzwKPWAsvr2Ju6LNvpDhOZf0iij7KCsmxna42HAWHVYtnO89k8qjdhNKsdgaAs23k2YfP/3mbZzmNBHrUxYXOeXpi9y+u46VrgRMIlUO1KCsfUMUNPwiOj1vm7XgIqs1Z7N6xm3JXaRMFa6nmUTFhkl2U7KxqAZTHMn8aBaWA+0FAiu1Pa7hxtN8pA+c4GPeJFpd+Aq7yCCn11jgD3Fmm3X0khfTYXAMPAgojO40r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https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"
],
"archive": "http://localhost:8080/api",
"reco": {
"host": "localhost",
"port": 8090,
"host": "recommender",
"port": 8080,
"reconnectInterval": 5000
}
}
......
The MIT License (MIT)
Copyright (c) 2015 Mark Adams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The xvfb-chromium script is part of the docker-chromium-xvfb project of Mark Adams.
The MIT licence of his project is included in this directory.
You can find his whole project at https://github.com/mark-adams/docker-chromium-xvfb
#!/bin/bash
_kill_procs() {
kill -TERM $chromium
wait $chromium
kill -TERM $xvfb
}
# Setup a trap to catch SIGTERM and relay it to child processes
trap _kill_procs SIGTERM
XVFB_WHD=${XVFB_WHD:-1280x720x16}
# Start Xvfb
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
xvfb=$!
export DISPLAY=:99
chromium --no-sandbox $@ &
chromium=$!
wait $chromium
wait $xvfb
version: '3.2'
services:
hublot:
build: .
image: linagora/hublot
depends_on:
- recommender
- kaldi-gstreamer
- selenium
recommender:
image: linagora/recommender
ports:
- "8080"
kaldi-gstreamer:
image: linagora/kaldi-gstreamer
ports:
- "80"
volumes:
- ${MODELS_PATH}:/opt/models
env_file: .env
environment:
- NB_WORKERS
- YAML
- MODELS_PATH
selenium:
image: selenium/standalone-chrome
ports:
- "4444"
volumes:
- ./media:/opt/media
......@@ -10,11 +10,18 @@ function resolveSequentially(f, elements) {
module.exports = config => ({
run: (controllerFilesList, server, room, clientConfig) => {
console.log('runner is up');
const client = webdriverio.remote(config.driver);
console.log('runner created client');
return client.init()
.then(() => console.log('runner: client started'))
.url(server + '/' + room)
.then(() => console.log('runner: connecting to url'))
.waitForVisible('#displayname', 30000)
.then(() => console.log('runner: displayname visible'))
.then(() => resolveSequentially(f => client.execute(f, room, clientConfig),
controllerFilesList))
.then(() => console.log('runner: modules resolved'))
.then(() => client.execute(() => {
setTimeout(() => {
/* eslint-disable no-undef */
......@@ -22,9 +29,12 @@ module.exports = config => ({
/* eslint-enable */
}, 500);
}))
.waitForVisible('#displayname', 30000)
.then(() => console.log('runner: robot started'))
.setValue('#displayname', clientConfig.name)
.click('.btn')
.waitForExist('//div[@video-id="video-thumb8"]', 30000);
.then(() => console.log('runner: button clicked'))
.waitForExist('//div[@video-id="video-thumb8"]', 30000)
.then(() => console.log('runner: video exists'))
.catch(err => console.log('runner: error %j', err));
}
});
......@@ -9,15 +9,12 @@
"test": "xo && jest",
"test:watch": "jest --watch",
"ci": "yarn && xo && jest --runInBand",
"setup": "yarn run selenium-standalone install && webdriver-manager update --versions.chrome=2.31 --gecko=false",
"webdriver-start": "./bin/webdriver-start",
"webdriver-stop": "./bin/webdriver-stop"
},
"dependencies": {
"mz": "2.6.0",
"selenium-standalone": "^6.5.0",
"webdriverio": "4.7.1",
"webdriver-manager": "12.0.6"
"webdriverio": "4.7.1"
},
"devDependencies": {
"jest": "20.0.0",
......
npm run webdriver-start
npm start
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment