From 1117ce4b5473f0c5b8470c5c35cf9154d9d2fe31 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 11 Oct 2018 15:50:27 +0900 Subject: [PATCH] =?UTF-8?q?Redis=E3=82=92=E3=82=AA=E3=83=97=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AB=E3=81=97=E3=81=9F=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/example.yml | 58 +++++++++++++++---------------- docs/setup.en.md | 4 +-- docs/setup.ja.md | 4 ++- src/config/types.ts | 4 +-- src/db/redis.ts | 4 +-- src/server/api/limitter.ts | 6 ++++ src/server/api/service/twitter.ts | 2 +- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index 0f38e593b6..ea83f9cfb8 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -60,11 +60,6 @@ mongodb: user: example-misskey-user pass: example-misskey-pass -redis: - host: localhost - port: 6379 - pass: example-pass - # Drive capacity of a local user (MB) localDriveCapacityMb: 256 @@ -122,47 +117,50 @@ drive: # Below settings are optional # +# Redis +#redis: +# host: localhost +# port: 6379 +# pass: example-pass + # Elasticsearch -# elasticsearch: -# host: localhost -# port: 9200 -# pass: null +#elasticsearch: +# host: localhost +# port: 9200 +# pass: null # reCAPTCHA -# recaptcha: -# site_key: example-site-key +#recaptcha: +# site_key: example-site-key # secret_key: example-secret-key # ServiceWorker -# sw: -# # Public key of VAPID -# public_key: example-sw-public-key - -# # Private key of VAPID -# private_key: example-sw-private-key - -# google_maps_api_key: example-google-maps-api-key +#sw: +# # Public key of VAPID +# public_key: example-sw-public-key +# +# # Private key of VAPID +# private_key: example-sw-private-key # Twitter integration # You need to set the oauth callback url as : https:///api/tw/cb -# twitter: -# consumer_key: example-twitter-consumer-key -# consumer_secret: example-twitter-consumer-secret-key +#twitter: +# consumer_key: example-twitter-consumer-key +# consumer_secret: example-twitter-consumer-secret-key # Ghost # Ghost account is an account used for the purpose of delegating # followers when putting users in the list. -# ghost: user-id-of-your-ghost-account +#ghost: user-id-of-your-ghost-account # Clustering -# clusterLimit: 1 +#clusterLimit: 1 # Summaly proxy -# summalyProxy: "http://example.com" +#summalyProxy: "http://example.com" # User recommendation -user_recommendation: - external: true - engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}} - timeout: 300000 - +#user_recommendation: +# external: true +# engine: http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}} +# timeout: 300000 diff --git a/docs/setup.en.md b/docs/setup.en.md index 23bcdcca98..e30297962b 100644 --- a/docs/setup.en.md +++ b/docs/setup.en.md @@ -24,12 +24,12 @@ Please install and setup these softwares: #### Dependencies :package: * **[Node.js](https://nodejs.org/en/)** * **[MongoDB](https://www.mongodb.com/)** >= 3.6 -* **[Redis](https://redis.io/)** ##### Optional +* [Redis](https://redis.io/) + * Redis is optional, but we strongly recommended to install it * [Elasticsearch](https://www.elastic.co/) - used to provide searching feature instead of MongoDB - *3.* Setup MongoDB ---------------------------------------------------------------- In root : diff --git a/docs/setup.ja.md b/docs/setup.ja.md index e1ed63cab4..df98e6a8c0 100644 --- a/docs/setup.ja.md +++ b/docs/setup.ja.md @@ -24,9 +24,11 @@ adduser --disabled-password --disabled-login misskey #### 依存関係 :package: * **[Node.js](https://nodejs.org/en/)** * **[MongoDB](https://www.mongodb.com/)** (3.6以上) -* **[Redis](https://redis.io/)** ##### オプション +* [Redis](https://redis.io/) + * Redisはオプションですが、インストールすることを強く推奨します。 + * インストールしなくていいのは、あなたのインスタンスが自分専用のときだけです * [Elasticsearch](https://www.elastic.co/) - 検索機能を向上させるために用います。 *3.* MongoDBの設定 diff --git a/src/config/types.ts b/src/config/types.ts index 5c7b8260db..5c2b554285 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -93,11 +93,9 @@ export type Source = { private_key: string; }; - google_maps_api_key: string; - clusterLimit?: number; - user_recommendation: { + user_recommendation?: { external: boolean; engine: string; timeout: number; diff --git a/src/db/redis.ts b/src/db/redis.ts index f8d66ebda0..48e3f4e43e 100644 --- a/src/db/redis.ts +++ b/src/db/redis.ts @@ -1,10 +1,10 @@ import * as redis from 'redis'; import config from '../config'; -export default redis.createClient( +export default config.redis ? redis.createClient( config.redis.port, config.redis.host, { auth_pass: config.redis.pass } -); +) : null; diff --git a/src/server/api/limitter.ts b/src/server/api/limitter.ts index 20a18a7098..abf7627ab8 100644 --- a/src/server/api/limitter.ts +++ b/src/server/api/limitter.ts @@ -8,6 +8,12 @@ import { IUser } from '../../models/user'; const log = debug('misskey:limitter'); export default (endpoint: IEndpoint, user: IUser) => new Promise((ok, reject) => { + // Redisがインストールされてない場合は常に許可 + if (limiterDB == null) { + ok(); + return; + } + const limitation = endpoint.meta.limit; const key = limitation.hasOwnProperty('key') diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index f71e588628..6c3cdaa138 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -55,7 +55,7 @@ router.get('/disconnect/twitter', async ctx => { })); }); -if (config.twitter == null) { +if (config.twitter == null || redis == null) { router.get('/connect/twitter', ctx => { ctx.body = '現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)'; });