diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-11-07 00:02:18 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-11-07 00:02:18 +0900 |
| commit | 873444c3c6f7e3b9ecb6cce569d8cdb3fa032012 (patch) | |
| tree | 30a52b7ac3025e92c0e9ce5c7028a96af83f7088 /src/queue/processors/deliver.ts | |
| parent | Resolve #5582 (#5583) (diff) | |
| download | sharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.gz sharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.bz2 sharkey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.zip | |
APの統計とログの修正と強化 (#5585)
* Fix #5580
* Improve AP logging
Diffstat (limited to 'src/queue/processors/deliver.ts')
| -rw-r--r-- | src/queue/processors/deliver.ts | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/queue/processors/deliver.ts b/src/queue/processors/deliver.ts index b252c20163..980ca3a437 100644 --- a/src/queue/processors/deliver.ts +++ b/src/queue/processors/deliver.ts @@ -5,6 +5,8 @@ import Logger from '../../services/logger'; import { Instances } from '../../models'; import { instanceChart } from '../../services/chart'; import { fetchNodeinfo } from '../../services/fetch-nodeinfo'; +import { fetchMeta } from '../../misc/fetch-meta'; +import { toPuny } from '../../misc/convert-host'; const logger = new Logger('deliver'); @@ -13,6 +15,23 @@ let latest: string | null = null; export default async (job: Bull.Job) => { const { host } = new URL(job.data.to); + // ブロックしてたら中断 + const meta = await fetchMeta(); + if (meta.blockedHosts.includes(toPuny(host))) { + return 'skip (blocked)'; + } + + // closedなら中断 + const closedHosts = await Instances.find({ + where: { + isMarkedAsClosed: true + }, + cache: 60 * 1000 + }); + if (closedHosts.map(x => x.host).includes(toPuny(host))) { + return 'skip (closed)'; + } + try { if (latest !== (latest = JSON.stringify(job.data.content, null, 2))) { logger.debug(`delivering ${latest}`); @@ -48,8 +67,6 @@ export default async (job: Bull.Job) => { }); if (res != null && res.hasOwnProperty('statusCode')) { - logger.warn(`deliver failed: ${res.statusCode} ${res.statusMessage} to=${job.data.to}`); - // 4xx if (res.statusCode >= 400 && res.statusCode < 500) { // HTTPステータスコード4xxはクライアントエラーであり、それはつまり @@ -61,7 +78,6 @@ export default async (job: Bull.Job) => { throw `${res.statusCode} ${res.statusMessage}`; } else { // DNS error, socket error, timeout ... - logger.warn(`deliver failed: ${res} to=${job.data.to}`); throw res; } } |