File tree 5 files changed +29
-12
lines changed 5 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def format_url(endpoint):
38
38
mail = Mail ()
39
39
oauth = OAuth ()
40
40
limiter = Limiter (
41
- storage_uri = EnvironmentConfig .MEMCACHED_URI ,
41
+ storage_uri = EnvironmentConfig .REDIS_URI ,
42
42
key_func = get_remote_address ,
43
43
headers_enabled = True ,
44
44
)
@@ -134,9 +134,9 @@ def add_api_endpoints(app):
134
134
"message" : "You have exceeded the rate limit. Please try again later." ,
135
135
"status" : 429 ,
136
136
},
137
- "MemcacheUnexpectedCloseError " : {
138
- "SubCode" : "MemcacheUnexpectedCloseError " ,
139
- "message" : "Connection to Memcache server lost ." ,
137
+ "ConnectionError " : {
138
+ "SubCode" : "RedisConnectionError " ,
139
+ "message" : "Connection to Redis server refused ." ,
140
140
"status" : 500 ,
141
141
},
142
142
}
Original file line number Diff line number Diff line change @@ -110,12 +110,12 @@ class EnvironmentConfig:
110
110
"TM_API_RATE_LIMIT_THRESHOLD" , "100 per hour"
111
111
)
112
112
# Memcache configuration
113
- MEMCACHED_PORT = os .getenv ("TM_MEMCACHE_PORT " , None )
114
- MEMCACHED_HOST = os .getenv ("TM_MEMCACHE_HOST " , None )
115
- if MEMCACHED_PORT and MEMCACHED_HOST :
116
- MEMCACHED_URI = f"memcached ://{ MEMCACHED_HOST } :{ MEMCACHED_PORT } "
113
+ REDIS_PORT = os .getenv ("TM_REDIS_PORT " , None )
114
+ REDIS_HOST = os .getenv ("TM_REDIS_HOST " , None )
115
+ if REDIS_PORT and REDIS_HOST :
116
+ REDIS_URI = f"redis ://{ REDIS_HOST } :{ REDIS_PORT } "
117
117
else :
118
- MEMCACHED_URI = None
118
+ REDIS_URI = None
119
119
120
120
# Languages offered by the Tasking Manager
121
121
# Please note that there must be exactly the same number of Codes as languages.
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ services:
17
17
<< : *backend
18
18
container_name : backend
19
19
restart : always
20
+ depends_on :
21
+ - postgresql
22
+ - redis
20
23
labels :
21
24
- traefik.http.routers.backend.rule=Host(`localhost`) && PathPrefix(`/api/`)
22
25
- traefik.http.services.backend.loadbalancer.server.port=5000
@@ -43,7 +46,14 @@ services:
43
46
env_file : ${ENV_FILE:-tasking-manager.env}
44
47
networks :
45
48
- tm-web
46
-
49
+ redis :
50
+ image : bitnami/redis:7.0.4
51
+ container_name : redis
52
+ environment :
53
+ - ALLOW_EMPTY_PASSWORD=yes
54
+ restart : always
55
+ networks :
56
+ - tm-web
47
57
traefik :
48
58
image : traefik:v2.3
49
59
restart : always
Original file line number Diff line number Diff line change @@ -149,7 +149,14 @@ POSTGRES_PASSWORD=tm
149
149
150
150
# If disabled project update emails will not be sent.
151
151
# Set it disabled in case of testing instances
152
- TM_SEND_PROJECT_EMAIL_UPDATES = 1
152
+ TM_SEND_PROJECT_EMAIL_UPDATES = 1
153
+
154
+ # Default threshold to rate limit api calls, seperated by comma
155
+ TM_API_RATE_LIMIT_THRESHOLD = 2/second, 100/hour
156
+
157
+ # Redis configuration for rate limiter storage(optional, in memory storage is used by default if not provided.).
158
+ TM_REDIS_HOST = localhost
159
+ TM_REDIS_PORT = 6379
153
160
154
161
# TM_SERVICE_DESK
155
162
# If the organisation has a service desk, configures the link
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ Mako==1.1.3
36
36
markdown == 3.3.3
37
37
MarkupSafe == 1.1.1
38
38
mccabe == 0.6.1
39
- pymemcache == 3.5.2
39
+ redis == 3.5.0
40
40
newrelic == 5.22.1.152
41
41
nose == 1.3.7
42
42
oauthlib == 2.0.2
You can’t perform that action at this time.
0 commit comments