aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 14:00:30 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:25 +0200
commit913b1d71e630d5a959c763bf565a171b4dc61434 (patch)
tree3f460b05fe15a242e0fd2328b8c245af9ced3c4c /shared/extra-utils/server
parent42e1ec25ece5ef6b7a29d64610e3729578059e52 (diff)
downloadPeerTube-913b1d71e630d5a959c763bf565a171b4dc61434.tar.gz
PeerTube-913b1d71e630d5a959c763bf565a171b4dc61434.tar.zst
PeerTube-913b1d71e630d5a959c763bf565a171b4dc61434.zip
Fix rerunserver function
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r--shared/extra-utils/server/servers.ts44
1 files changed, 24 insertions, 20 deletions
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index add738056..3ef4b9746 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -87,7 +87,7 @@ function randomServer () {
87 return Math.floor(Math.random() * (high - low) + low) 87 return Math.floor(Math.random() * (high - low) + low)
88} 88}
89 89
90async function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) { 90async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) {
91 const parallel = process.env.MOCHA_PARALLEL === 'true' 91 const parallel = process.env.MOCHA_PARALLEL === 'true'
92 92
93 const internalServerNumber = parallel ? randomServer() : serverNumber 93 const internalServerNumber = parallel ? randomServer() : serverNumber
@@ -113,11 +113,15 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
113 } 113 }
114 } 114 }
115 115
116 return runServer(server, configOverride, args)
117}
118
119function runServer (server: ServerInfo, configOverrideArg?: any, args = []) {
116 // These actions are async so we need to be sure that they have both been done 120 // These actions are async so we need to be sure that they have both been done
117 const serverRunString = { 121 const serverRunString = {
118 'Server listening': false 122 'Server listening': false
119 } 123 }
120 const key = 'Database peertube_test' + internalServerNumber + ' is ready' 124 const key = 'Database peertube_test' + server.internalServerNumber + ' is ready'
121 serverRunString[key] = false 125 serverRunString[key] = false
122 126
123 const regexps = { 127 const regexps = {
@@ -130,36 +134,36 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
130 // Share the environment 134 // Share the environment
131 const env = Object.create(process.env) 135 const env = Object.create(process.env)
132 env['NODE_ENV'] = 'test' 136 env['NODE_ENV'] = 'test'
133 env['NODE_APP_INSTANCE'] = serverNumber.toString() 137 env['NODE_APP_INSTANCE'] = server.serverNumber.toString()
134 138
135 let configOverride: any = {} 139 let configOverride: any = {}
136 140
137 if (parallel) { 141 if (server.parallel) {
138 configOverride = { 142 configOverride = {
139 listen: { 143 listen: {
140 port: port 144 port: server.port
141 }, 145 },
142 webserver: { 146 webserver: {
143 port: port 147 port: server.port
144 }, 148 },
145 database: { 149 database: {
146 suffix: '_test' + internalServerNumber 150 suffix: '_test' + server.internalServerNumber
147 }, 151 },
148 storage: { 152 storage: {
149 tmp: `test${internalServerNumber}/tmp/`, 153 tmp: `test${server.internalServerNumber}/tmp/`,
150 avatars: `test${internalServerNumber}/avatars/`, 154 avatars: `test${server.internalServerNumber}/avatars/`,
151 videos: `test${internalServerNumber}/videos/`, 155 videos: `test${server.internalServerNumber}/videos/`,
152 streaming_playlists: `test${internalServerNumber}/streaming-playlists/`, 156 streaming_playlists: `test${server.internalServerNumber}/streaming-playlists/`,
153 redundancy: `test${internalServerNumber}/redundancy/`, 157 redundancy: `test${server.internalServerNumber}/redundancy/`,
154 logs: `test${internalServerNumber}/logs/`, 158 logs: `test${server.internalServerNumber}/logs/`,
155 previews: `test${internalServerNumber}/previews/`, 159 previews: `test${server.internalServerNumber}/previews/`,
156 thumbnails: `test${internalServerNumber}/thumbnails/`, 160 thumbnails: `test${server.internalServerNumber}/thumbnails/`,
157 torrents: `test${internalServerNumber}/torrents/`, 161 torrents: `test${server.internalServerNumber}/torrents/`,
158 captions: `test${internalServerNumber}/captions/`, 162 captions: `test${server.internalServerNumber}/captions/`,
159 cache: `test${internalServerNumber}/cache/` 163 cache: `test${server.internalServerNumber}/cache/`
160 }, 164 },
161 admin: { 165 admin: {
162 email: `admin${internalServerNumber}@example.com` 166 email: `admin${server.internalServerNumber}@example.com`
163 } 167 }
164 } 168 }
165 } 169 }
@@ -216,7 +220,7 @@ async function flushAndRunServer (serverNumber: number, configOverrideArg?: Obje
216} 220}
217 221
218async function reRunServer (server: ServerInfo, configOverride?: any) { 222async function reRunServer (server: ServerInfo, configOverride?: any) {
219 const newServer = await flushAndRunServer(server.serverNumber, configOverride) 223 const newServer = await runServer(server, configOverride)
220 server.app = newServer.app 224 server.app = newServer.app
221 225
222 return server 226 return server