Skip to content

Commit 70acc22

Browse files
authored
Merge pull request #637 from RNAcentral/update-gunicorn
Update gunicorn
2 parents 6b09607 + 318ea64 commit 70acc22

File tree

10 files changed

+101
-18
lines changed

10 files changed

+101
-18
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ name: Building Docker containers
1010
on:
1111
push:
1212
paths-ignore:
13-
- 'jenkins/**'
1413
- 'kubernetes/**'
1514
- 'nginx/**'
1615
- 'openssl/**'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ USER rnacentral
7070
COPY ./entrypoint.sh $RNACENTRAL_HOME
7171
ENTRYPOINT ["/srv/rnacentral/rnacentral-webcode/entrypoint.sh"]
7272

73-
CMD ["gunicorn", "--chdir", "/srv/rnacentral/rnacentral-webcode/rnacentral", "--bind", "0.0.0.0:8000", "rnacentral.wsgi:application", "--workers", "2", "--timeout", "120", "--max-requests", "1000", "--max-requests-jitter", "100", "--log-level=debug", "--access-logfile", "/dev/stdout", "--error-logfile", "/dev/stderr"]
73+
CMD ["gunicorn", "--chdir", "/srv/rnacentral/rnacentral-webcode/rnacentral", "--bind", "0.0.0.0:8000", "rnacentral.wsgi:application", "--workers", "4", "--threads", "2", "--timeout", "120", "--graceful-timeout", "60", "--keep-alive", "10", "--max-requests", "1000", "--max-requests-jitter", "100", "--log-level=debug", "--access-logfile", "/dev/stdout", "--error-logfile", "/dev/stderr"]

entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ else
5757
"PASSWORD": "$DB_PASSWORD",
5858
"HOST": "$DB_HOST",
5959
"PORT": "$DB_PORT",
60+
"CONN_MAX_AGE": 0
6061
}
6162
}
6263
EOF

kubernetes/helm/templates/nginx.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ data:
3030
access_log stdout;
3131
error_log stderr;
3232
33+
if ($http_user_agent ~* (Ahrefs|MJ12bot|Semrush|Yandex|facebookexternal|developers\.facebook\.com)) {
34+
return 403;
35+
}
36+
3337
location /static/ {
3438
autoindex on;
3539
alias /srv/rnacentral/static/;
@@ -41,6 +45,25 @@ data:
4145
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4246
proxy_set_header Host $host;
4347
proxy_redirect off;
48+
49+
proxy_read_timeout 120;
50+
proxy_send_timeout 120;
51+
proxy_connect_timeout 120;
52+
}
53+
54+
error_page 500 502 503 504 /error/;
55+
location /error/ {
56+
internal;
57+
proxy_pass http://rnacentral/error/;
58+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59+
proxy_set_header Host $host;
60+
proxy_redirect off;
61+
}
62+
63+
location /nginx_status {
64+
stub_status;
65+
allow 127.0.0.1;
66+
deny all;
4467
}
4568
}
4669
---

locust/locustfile.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
######
2+
# This tool was used to simulate access to the website
3+
# by hundreds of users and check the behavior of the
4+
# server and database. Run the load testing tool with:
5+
#
6+
# locust -f locustfile.py --host=http://localhost:8010
7+
#
8+
######
9+
10+
import random
11+
12+
from locust import HttpUser, TaskSet, between, task
13+
14+
# The urs_list.txt file is just an example and therefore
15+
# contains a small list of URS
16+
with open("urs_list.txt", "r") as f:
17+
urs = [line.strip() for line in f.readlines()]
18+
19+
20+
class UserBehavior(TaskSet):
21+
@task
22+
def fetch_sequence_page(self):
23+
random_urs = random.choice(urs)
24+
self.client.get(f"/rna/{random_urs}")
25+
26+
27+
class WebsiteUser(HttpUser):
28+
tasks = [UserBehavior]
29+
wait_time = between(1, 3)

locust/urs_list.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
URS0000000055_9606
2+
URS0000000096_9606
3+
URS0000000098_9606
4+
URS00000000C9_9606
5+
URS00000000D2_9606
6+
URS00000000FD_9606
7+
URS0000000185_9606
8+
URS000000022A_9606
9+
URS000000023A_9606
10+
URS00000002D9_9606

nginx/conf.d/local.conf

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ upstream rnacentral {
55

66
server {
77
listen 80;
8+
root /srv/rnacentral/static/;
9+
access_log stdout;
10+
error_log stderr;
11+
12+
location /static/ {
13+
autoindex on;
14+
alias /srv/rnacentral/static/;
15+
}
816

917
location / {
1018
# everything is passed to Gunicorn
@@ -15,11 +23,15 @@ server {
1523

1624
proxy_read_timeout 120;
1725
proxy_send_timeout 120;
18-
proxy_connect_timeout 75;
26+
proxy_connect_timeout 120;
1927
}
2028

21-
location /static/ {
22-
autoindex on;
23-
alias /srv/rnacentral/static/;
29+
error_page 500 502 503 504 /error/;
30+
location /error/ {
31+
internal;
32+
proxy_pass http://rnacentral/error/;
33+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34+
proxy_set_header Host $host;
35+
proxy_redirect off;
2436
}
2537
}

rnacentral/portal/templates/portal/base.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@
8989
<link rel="apple-touch-icon" sizes="144x144" href="{% static "img/icons/apple-touch-icon-144x144.png" %}" />
9090
<link rel="apple-touch-icon" sizes="152x152" href="{% static "img/icons/apple-touch-icon-152x152.png" %}" />
9191

92+
<!-- Google tag (gtag.js) -->
93+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-37T22PHH90"></script>
94+
<script>
95+
window.dataLayer = window.dataLayer || [];
96+
function gtag(){dataLayer.push(arguments);}
97+
gtag('js', new Date());
98+
99+
gtag('config', 'G-37T22PHH90');
100+
</script>
101+
92102
{% block extra_head %}{% endblock %}
93103
</head>
94104

@@ -260,16 +270,6 @@
260270
{% block extra_js_uncompressed %}
261271
{% endblock %}
262272

263-
<!-- Google tag (gtag.js) -->
264-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-37T22PHH90"></script>
265-
<script>
266-
window.dataLayer = window.dataLayer || [];
267-
function gtag(){dataLayer.push(arguments);}
268-
gtag('js', new Date());
269-
270-
gtag('config', 'G-37T22PHH90');
271-
</script>
272-
273273
<!--Doorbell.io feedback-->
274274
<script type="text/javascript">
275275
window.doorbellOptions = {

rnacentral/requirements_dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ mock==4.0.3
77

88
# pre-commit hooks
99
pre-commit==2.20.0
10+
11+
# performance/load testing tool
12+
locust==2.32.3

rnacentral/templates/robots.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
User-agent: AhrefsBot
2+
User-agent: CCBot
3+
User-agent: ClaudeBot
24
User-agent: DotBot
5+
User-agent: FacebookBot
6+
User-agent: GPTBot
37
User-agent: MJ12bot
48
User-agent: PetalBot
9+
User-agent: SeekportBot
510
User-agent: SEMrushBot
611
Disallow: /
7-
Disallow: /sitemap.xml
812

913
User-agent: *
14+
Crawl-delay: 5
15+
Disallow: /api/current/
16+
Disallow: /api/v1/
1017
Disallow: /export/
1118
Disallow: /sequence-search/
12-
Allow: /sitemap.xml
1319

1420
Sitemap: https://rnacentral.org/sitemap.xml

0 commit comments

Comments
 (0)