aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server.ts7
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-broadcast.ts17
3 files changed, 13 insertions, 13 deletions
diff --git a/server.ts b/server.ts
index 5323bae2b..8024655a3 100644
--- a/server.ts
+++ b/server.ts
@@ -215,7 +215,8 @@ async function startApplication () {
215 Redis.Instance.init() 215 Redis.Instance.init()
216 216
217 // Make server listening 217 // Make server listening
218 server.listen(port, hostname) 218 server.listen(port, hostname, () => {
219 logger.info('Server listening on %s:%d', hostname, port) 219 logger.info('Server listening on %s:%d', hostname, port)
220 logger.info('Web server: %s', CONFIG.WEBSERVER.URL) 220 logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
221 })
221} 222}
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index ffcbe69b8..5ee13389d 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -77,6 +77,7 @@ const JOB_CONCURRENCY: { [ id in JobType ]: number } = {
77 'video-file': 1, 77 'video-file': 1,
78 'email': 5 78 'email': 5
79} 79}
80const BROADCAST_CONCURRENCY = 5 // How many requests in parallel we do in activitypub-http-broadcast job
80// 2 days 81// 2 days
81const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 82const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2
82 83
@@ -463,6 +464,7 @@ export {
463 LAST_MIGRATION_VERSION, 464 LAST_MIGRATION_VERSION,
464 OAUTH_LIFETIME, 465 OAUTH_LIFETIME,
465 OPENGRAPH_AND_OEMBED_COMMENT, 466 OPENGRAPH_AND_OEMBED_COMMENT,
467 BROADCAST_CONCURRENCY,
466 PAGINATION_COUNT_DEFAULT, 468 PAGINATION_COUNT_DEFAULT,
467 ACTOR_FOLLOW_SCORE, 469 ACTOR_FOLLOW_SCORE,
468 PREVIEWS_SIZE, 470 PREVIEWS_SIZE,
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
index 78878fc01..38b8393f4 100644
--- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
@@ -1,8 +1,10 @@
1import * as kue from 'kue' 1import * as kue from 'kue'
2import * as Bluebird from 'bluebird'
2import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
3import { doRequest } from '../../../helpers/requests' 4import { doRequest } from '../../../helpers/requests'
4import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 5import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
5import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 6import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
7import { BROADCAST_CONCURRENCY } from '../../../initializers'
6 8
7export type ActivitypubHttpBroadcastPayload = { 9export type ActivitypubHttpBroadcastPayload = {
8 uris: string[] 10 uris: string[]
@@ -28,16 +30,11 @@ async function processActivityPubHttpBroadcast (job: kue.Job) {
28 const badUrls: string[] = [] 30 const badUrls: string[] = []
29 const goodUrls: string[] = [] 31 const goodUrls: string[] = []
30 32
31 for (const uri of payload.uris) { 33 await Bluebird.map(payload.uris, uri => {
32 options.uri = uri 34 return doRequest(Object.assign({}, options, { uri }))
33 35 .then(() => goodUrls.push(uri))
34 try { 36 .catch(() => badUrls.push(uri))
35 await doRequest(options) 37 }, { concurrency: BROADCAST_CONCURRENCY })
36 goodUrls.push(uri)
37 } catch (err) {
38 badUrls.push(uri)
39 }
40 }
41 38
42 return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined) 39 return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined)
43} 40}