Fix rerunserver function
This commit is contained in:
parent
42e1ec25ec
commit
913b1d71e6
|
@ -87,7 +87,7 @@ function randomServer () {
|
||||||
return Math.floor(Math.random() * (high - low) + low)
|
return Math.floor(Math.random() * (high - low) + low)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) {
|
async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) {
|
||||||
const parallel = process.env.MOCHA_PARALLEL === 'true'
|
const parallel = process.env.MOCHA_PARALLEL === 'true'
|
||||||
|
|
||||||
const internalServerNumber = parallel ? randomServer() : serverNumber
|
const internalServerNumber = parallel ? randomServer() : serverNumber
|
||||||
|
@ -113,11 +113,15 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return runServer(server, configOverride, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
function runServer (server: ServerInfo, configOverrideArg?: any, args = []) {
|
||||||
// These actions are async so we need to be sure that they have both been done
|
// These actions are async so we need to be sure that they have both been done
|
||||||
const serverRunString = {
|
const serverRunString = {
|
||||||
'Server listening': false
|
'Server listening': false
|
||||||
}
|
}
|
||||||
const key = 'Database peertube_test' + internalServerNumber + ' is ready'
|
const key = 'Database peertube_test' + server.internalServerNumber + ' is ready'
|
||||||
serverRunString[key] = false
|
serverRunString[key] = false
|
||||||
|
|
||||||
const regexps = {
|
const regexps = {
|
||||||
|
@ -130,36 +134,36 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
|
||||||
// Share the environment
|
// Share the environment
|
||||||
const env = Object.create(process.env)
|
const env = Object.create(process.env)
|
||||||
env['NODE_ENV'] = 'test'
|
env['NODE_ENV'] = 'test'
|
||||||
env['NODE_APP_INSTANCE'] = serverNumber.toString()
|
env['NODE_APP_INSTANCE'] = server.serverNumber.toString()
|
||||||
|
|
||||||
let configOverride: any = {}
|
let configOverride: any = {}
|
||||||
|
|
||||||
if (parallel) {
|
if (server.parallel) {
|
||||||
configOverride = {
|
configOverride = {
|
||||||
listen: {
|
listen: {
|
||||||
port: port
|
port: server.port
|
||||||
},
|
},
|
||||||
webserver: {
|
webserver: {
|
||||||
port: port
|
port: server.port
|
||||||
},
|
},
|
||||||
database: {
|
database: {
|
||||||
suffix: '_test' + internalServerNumber
|
suffix: '_test' + server.internalServerNumber
|
||||||
},
|
},
|
||||||
storage: {
|
storage: {
|
||||||
tmp: `test${internalServerNumber}/tmp/`,
|
tmp: `test${server.internalServerNumber}/tmp/`,
|
||||||
avatars: `test${internalServerNumber}/avatars/`,
|
avatars: `test${server.internalServerNumber}/avatars/`,
|
||||||
videos: `test${internalServerNumber}/videos/`,
|
videos: `test${server.internalServerNumber}/videos/`,
|
||||||
streaming_playlists: `test${internalServerNumber}/streaming-playlists/`,
|
streaming_playlists: `test${server.internalServerNumber}/streaming-playlists/`,
|
||||||
redundancy: `test${internalServerNumber}/redundancy/`,
|
redundancy: `test${server.internalServerNumber}/redundancy/`,
|
||||||
logs: `test${internalServerNumber}/logs/`,
|
logs: `test${server.internalServerNumber}/logs/`,
|
||||||
previews: `test${internalServerNumber}/previews/`,
|
previews: `test${server.internalServerNumber}/previews/`,
|
||||||
thumbnails: `test${internalServerNumber}/thumbnails/`,
|
thumbnails: `test${server.internalServerNumber}/thumbnails/`,
|
||||||
torrents: `test${internalServerNumber}/torrents/`,
|
torrents: `test${server.internalServerNumber}/torrents/`,
|
||||||
captions: `test${internalServerNumber}/captions/`,
|
captions: `test${server.internalServerNumber}/captions/`,
|
||||||
cache: `test${internalServerNumber}/cache/`
|
cache: `test${server.internalServerNumber}/cache/`
|
||||||
},
|
},
|
||||||
admin: {
|
admin: {
|
||||||
email: `admin${internalServerNumber}@example.com`
|
email: `admin${server.internalServerNumber}@example.com`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +220,7 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
||||||
const newServer = await flushAndRunServer(server.serverNumber, configOverride)
|
const newServer = await runServer(server, configOverride)
|
||||||
server.app = newServer.app
|
server.app = newServer.app
|
||||||
|
|
||||||
return server
|
return server
|
||||||
|
|
Loading…
Reference in New Issue