aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-26 10:36:24 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commitcef534ed53e4518fe0acf581bfe880788d42fc36 (patch)
tree115b51ea5136849a2336d44915c7780649f25dc2 /shared/utils/server
parent1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff)
downloadPeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz
PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst
PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip
Add user notification base code
Diffstat (limited to 'shared/utils/server')
-rw-r--r--shared/utils/server/jobs.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/shared/utils/server/jobs.ts b/shared/utils/server/jobs.ts
index f4623f896..6218c0b66 100644
--- a/shared/utils/server/jobs.ts
+++ b/shared/utils/server/jobs.ts
@@ -35,10 +35,10 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
35 else servers = serversArg as ServerInfo[] 35 else servers = serversArg as ServerInfo[]
36 36
37 const states: JobState[] = [ 'waiting', 'active', 'delayed' ] 37 const states: JobState[] = [ 'waiting', 'active', 'delayed' ]
38 const tasks: Promise<any>[] = [] 38 let pendingRequests = false
39 let pendingRequests: boolean
40 39
41 do { 40 function tasksBuilder () {
41 const tasks: Promise<any>[] = []
42 pendingRequests = false 42 pendingRequests = false
43 43
44 // Check if each server has pending request 44 // Check if each server has pending request
@@ -54,13 +54,16 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
54 } 54 }
55 } 55 }
56 56
57 await Promise.all(tasks) 57 return tasks
58 }
59
60 do {
61 await Promise.all(tasksBuilder())
58 62
59 // Retry, in case of new jobs were created 63 // Retry, in case of new jobs were created
60 if (pendingRequests === false) { 64 if (pendingRequests === false) {
61 await wait(2000) 65 await wait(2000)
62 66 await Promise.all(tasksBuilder())
63 await Promise.all(tasks)
64 } 67 }
65 68
66 if (pendingRequests) { 69 if (pendingRequests) {