Filter instance in bulk
This commit is contained in:
parent
fde7007788
commit
69e17e2777
|
@ -29,6 +29,7 @@ instances-index:
|
||||||
- 'replay.jres.org'
|
- 'replay.jres.org'
|
||||||
- 'tube.nah.re'
|
- 'tube.nah.re'
|
||||||
- 'video.passageenseine.fr'
|
- 'video.passageenseine.fr'
|
||||||
|
- 'peertube.luga.at'
|
||||||
|
|
||||||
api:
|
api:
|
||||||
blacklist:
|
blacklist:
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { CONFIG } from '../../initializers/constants'
|
||||||
import { listIndexInstancesHost, getMajorInstanceVersion } from '../requests/instances-index'
|
import { listIndexInstancesHost, getMajorInstanceVersion } from '../requests/instances-index'
|
||||||
import { client } from '../../helpers/meilisearch'
|
import { client } from '../../helpers/meilisearch'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
import Bluebird from 'bluebird'
|
||||||
|
|
||||||
async function buildInstanceHosts () {
|
async function buildInstanceHosts () {
|
||||||
let indexHosts = await listIndexInstancesHost()
|
let indexHosts = await listIndexInstancesHost()
|
||||||
|
@ -14,16 +15,18 @@ async function buildInstanceHosts () {
|
||||||
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
|
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const indexHost of indexHosts) {
|
indexHosts = await Bluebird.filter(indexHosts, async indexHost => {
|
||||||
const instanceVersion = await getMajorInstanceVersion(indexHost)
|
const instanceVersion = await getMajorInstanceVersion(indexHost)
|
||||||
|
|
||||||
if (instanceVersion < 4) {
|
if (instanceVersion < 4) {
|
||||||
logger.info(`Do not index ${indexHost} because the major version is too low (v${instanceVersion} < v4)`)
|
logger.info(`Do not index ${indexHost} because the major version is too low (v${instanceVersion} < v4)`)
|
||||||
|
|
||||||
indexHosts = indexHosts.filter(h => h !== indexHost)
|
return false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}, { concurrency: 10 })
|
||||||
|
|
||||||
const dbHosts = await listDBInstances()
|
const dbHosts = await listDBInstances()
|
||||||
const removedHosts = getRemovedHosts(dbHosts, indexHosts)
|
const removedHosts = getRemovedHosts(dbHosts, indexHosts)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue