aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/index.ts37
-rw-r--r--shared/extra-utils/server/debug.ts19
-rw-r--r--shared/extra-utils/server/jobs.ts23
-rw-r--r--shared/models/server/index.ts1
-rw-r--r--shared/models/server/server-debug.model.ts4
5 files changed, 61 insertions, 23 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 8f5c709ff..5c95a1b3e 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -1,32 +1,33 @@
1export * from './server/activitypub'
2export * from './bulk/bulk' 1export * from './bulk/bulk'
3export * from './cli/cli' 2export * from './cli/cli'
4export * from './server/clients' 3export * from './feeds/feeds'
5export * from './server/config' 4export * from './instances-index/mock-instances-index'
6export * from './server/jobs'
7export * from './users/login'
8export * from './miscs/miscs' 5export * from './miscs/miscs'
9export * from './miscs/stubs'
10export * from './miscs/sql' 6export * from './miscs/sql'
11export * from './server/follows' 7export * from './miscs/stubs'
12export * from './requests/requests' 8export * from './moderation/abuses'
9export * from './plugins/mock-blocklist'
13export * from './requests/check-api-params' 10export * from './requests/check-api-params'
14export * from './server/servers' 11export * from './requests/requests'
12export * from './search/videos'
13export * from './server/activitypub'
14export * from './server/clients'
15export * from './server/config'
16export * from './server/debug'
17export * from './server/follows'
18export * from './server/jobs'
15export * from './server/plugins' 19export * from './server/plugins'
16export * from './videos/video-playlists' 20export * from './server/servers'
17export * from './users/users'
18export * from './users/accounts' 21export * from './users/accounts'
19export * from './moderation/abuses' 22export * from './users/login'
20export * from './videos/services' 23export * from './users/users'
21export * from './videos/live' 24export * from './videos/live'
25export * from './videos/services'
22export * from './videos/video-blacklist' 26export * from './videos/video-blacklist'
23export * from './videos/video-captions' 27export * from './videos/video-captions'
28export * from './videos/video-change-ownership'
24export * from './videos/video-channels' 29export * from './videos/video-channels'
25export * from './videos/video-comments' 30export * from './videos/video-comments'
31export * from './videos/video-playlists'
26export * from './videos/video-streaming-playlists' 32export * from './videos/video-streaming-playlists'
27export * from './videos/videos' 33export * from './videos/videos'
28export * from './videos/video-change-ownership'
29export * from './feeds/feeds'
30export * from './instances-index/mock-instances-index'
31export * from './search/videos'
32export * from './plugins/mock-blocklist'
diff --git a/shared/extra-utils/server/debug.ts b/shared/extra-utils/server/debug.ts
new file mode 100644
index 000000000..5cf80a5fb
--- /dev/null
+++ b/shared/extra-utils/server/debug.ts
@@ -0,0 +1,19 @@
1import { makeGetRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3
4function getDebug (url: string, token: string) {
5 const path = '/api/v1/server/debug'
6
7 return makeGetRequest({
8 url,
9 path,
10 token,
11 statusCodeExpected: HttpStatusCode.OK_200
12 })
13}
14
15// ---------------------------------------------------------------------------
16
17export {
18 getDebug
19}
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index a53749589..97971f960 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -1,7 +1,7 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { makeGetRequest } from '../../../shared/extra-utils' 3import { getDebug, makeGetRequest } from '../../../shared/extra-utils'
4import { Job, JobState, JobType } from '../../models' 4import { Job, JobState, JobType, ServerDebug } from '../../models'
5import { wait } from '../miscs/miscs' 5import { wait } from '../miscs/miscs'
6import { ServerInfo } from './servers' 6import { ServerInfo } from './servers'
7 7
@@ -53,7 +53,10 @@ function getJobsListPaginationAndSort (options: {
53} 53}
54 54
55async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { 55async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
56 const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) : 2000 56 const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT
57 ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10)
58 : 500
59
57 let servers: ServerInfo[] 60 let servers: ServerInfo[]
58 61
59 if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ] 62 if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ]
@@ -75,16 +78,26 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
75 start: 0, 78 start: 0,
76 count: 10, 79 count: 10,
77 sort: '-createdAt' 80 sort: '-createdAt'
78 }) 81 }).then(res => res.body.data)
79 .then(res => res.body.data)
80 .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views')) 82 .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views'))
81 .then(jobs => { 83 .then(jobs => {
82 if (jobs.length !== 0) { 84 if (jobs.length !== 0) {
83 pendingRequests = true 85 pendingRequests = true
84 } 86 }
85 }) 87 })
88
86 tasks.push(p) 89 tasks.push(p)
87 } 90 }
91
92 const p = getDebug(server.url, server.accessToken)
93 .then(res => res.body)
94 .then((obj: ServerDebug) => {
95 if (obj.activityPubMessagesWaiting !== 0) {
96 pendingRequests = true
97 }
98 })
99
100 tasks.push(p)
88 } 101 }
89 102
90 return tasks 103 return tasks
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts
index f253a3a79..b5163954a 100644
--- a/shared/models/server/index.ts
+++ b/shared/models/server/index.ts
@@ -7,5 +7,6 @@ export * from './emailer.model'
7export * from './job.model' 7export * from './job.model'
8export * from './log-level.type' 8export * from './log-level.type'
9export * from './server-config.model' 9export * from './server-config.model'
10export * from './server-debug.model'
10export * from './server-error-code.enum' 11export * from './server-error-code.enum'
11export * from './server-stats.model' 12export * from './server-stats.model'
diff --git a/shared/models/server/server-debug.model.ts b/shared/models/server/server-debug.model.ts
new file mode 100644
index 000000000..4b731bb90
--- /dev/null
+++ b/shared/models/server/server-debug.model.ts
@@ -0,0 +1,4 @@
1export interface ServerDebug {
2 ip: string
3 activityPubMessagesWaiting: number
4}