From c4c77836917c367ff93d2ea47ce9142b44cc19e0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 4 Feb 2019 10:03:49 +0900 Subject: [PATCH] [Server] Enable slow option --- src/argv.ts | 1 + src/server/index.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/argv.ts b/src/argv.ts index da22e5fdfc..211b42a529 100644 --- a/src/argv.ts +++ b/src/argv.ts @@ -6,6 +6,7 @@ program .option('--no-daemons', 'Disable daemon processes (for debbuging)') .option('--disable-clustering', 'Disable clustering') .option('--quiet', 'Suppress all logs') + .option('--slow', 'Delay all requests (for debbuging)') .parse(process.argv); export { program }; diff --git a/src/server/index.ts b/src/server/index.ts index be0a6f5c77..26fa06d111 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -13,7 +13,7 @@ import * as mount from 'koa-mount'; import * as compress from 'koa-compress'; import * as koaLogger from 'koa-logger'; import * as requestStats from 'request-stats'; -//import * as slow from 'koa-slow'; +import * as slow from 'koa-slow'; import activityPub from './activitypub'; import webFinger from './webfinger'; @@ -23,6 +23,7 @@ import apiServer from './api'; import { sum } from '../prelude/array'; import User from '../models/user'; import Logger from '../misc/logger'; +import { program } from '../argv'; export const serverLogger = new Logger('server', 'gray'); @@ -37,9 +38,11 @@ if (!['production', 'test'].includes(process.env.NODE_ENV)) { })); // Delay - //app.use(slow({ - // delay: 1000 - //})); + if (program.slow) { + app.use(slow({ + delay: 3000 + })); + } } // Compress response