-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccc.js
56 lines (48 loc) · 1.45 KB
/
ccc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* CoteJS Connection Checker */
'use strict'
const shell = require('shelljs')
const shortid = require('shortid')
/* problem/
* Many firewalls block cotejs connection mechanisms
* and therefore the avartar will not work.
*
* way/
* We check if we can make a simple CoteJS connection
* and, if we can, we exit so the user can proceed.
* Otherwise (if it's taking a while), we show the user
* a helpful message so they know what to do.
*/
function main() {
shell.echo(`\n\nChecking Cote.js connection...`)
setTimeout(() => {
shell.echo(`
If this test does not exit then the microservices layer
is blocked and the Avatar's components will not be able
to communicate with each other.
In order to continue you need to configure your firewall
to allow the avatar's communication to work`)
}, 3000)
checkCoteConnection(() => {
shell.echo('CoteJS Connection check passed - ok!')
})
}
function checkCoteConnection(cb) {
shell.env['COTE_ENV'] = shortid.generate()
const cote = require('cote')({statusLogsEnabled:false})
const resp = new cote.Responder({
name: 'Cote Connection Check',
key: 'everlife-cote-check',
})
resp.on('check', (req, cb) => {
cb('ok')
})
const req = new cote.Requester({
name: 'Cote Check Client',
key: 'everlife-cote-check',
})
req.send({ type: 'check' }, (r) => {
if(r == 'ok') cb()
shell.exit()
})
}
main()