-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
45 lines (36 loc) · 1.07 KB
/
test.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
const { version: VERSION } = require('./package.json')
const DDAtHome = require('./core')
const interval = 480
const url = new URL('wss://cluster.vtbs.moe')
url.searchParams.set('runtime', `node${process.version}`)
url.searchParams.set('version', VERSION)
url.searchParams.set('platform', process.platform)
if (process.env.docker) {
url.searchParams.set('docker', 'docker')
}
const name = `CI-Runner-${Math.random()}`
url.searchParams.set('name', name)
const ws = new DDAtHome(url, { INTERVAL: interval })
ws.on('log', console.log)
let resolves = 0
ws.on('done', () => resolves++)
setInterval(async () => {
if (resolves > 5) {
const homes = await ws.ask('homes').catch(() => {
console.error('ask reject')
process.exit(1)
})
const current = homes.find(({ name: n }) => n === name)
if (!current) {
console.error('no current')
process.exit(1)
}
if (current.resolves <= 0) {
console.error('no resolve')
process.exit(1)
}
console.log('all right')
console.log({ resolves, current })
process.exit(0)
}
}, 1000 * 5)