質問編集履歴
2
不要部位の消去
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,18 +1,4 @@
|
|
1
|
-
nginxでのエラーで,
|
2
|
-
|
3
|
-
処理時間が長すぎる
|
4
|
-
|
5
|
-
→504 timeout
|
6
|
-
|
7
|
-
その他
|
8
|
-
|
9
|
-
→502 error
|
10
|
-
|
11
|
-
という認識で相違ないでしょうか?
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
現在djangoで開発している中で502が出る時があり,それは処理するファイルが大きく,実行時間が長い時です。
|
16
2
|
|
17
3
|
エラーログは以下の通りで,
|
18
4
|
|
1
gunicornのtimeoutと仮定し,行なった対策を追記。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,12 +14,182 @@
|
|
14
14
|
|
15
15
|
また,現在djangoで開発している中で502が出る時があり,それは処理するファイルが大きく,実行時間が長い時です。
|
16
16
|
|
17
|
+
エラーログは以下の通りで,
|
18
|
+
|
19
|
+
```errorLog
|
20
|
+
|
17
|
-
|
21
|
+
upstream prematurely closed connection while reading response header from upstream, client
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
[こちらQiita記事](https://qiita.com/yutackall/items/e1d8bd8ebe8a992578e5)を参考にしたところ,gunicorn側のtimeoutなのではないかと思っています。(アプリ側はdebug=trueですがエラーは出ないです)
|
18
26
|
|
19
27
|
|
20
28
|
|
21
|
-
|
29
|
+
そのため,gunicorn.confとnginx.confを以下のように設定しましたが,gunicorn.confの設定でtimeout 3600; を追加するとエラーが出て,またそれ抜きの設定では502になります。
|
22
30
|
|
23
|
-
もしくは502
|
24
31
|
|
32
|
+
|
33
|
+
どのようにすれば長い処理でもkillされないtimeoutの設定にできますか?
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```gunicornConf
|
38
|
+
|
39
|
+
server {
|
40
|
+
|
41
|
+
listen 80;
|
42
|
+
|
25
|
-
|
43
|
+
server_name IPアドレス;
|
44
|
+
|
45
|
+
keepalive_timeout 3600;
|
46
|
+
|
47
|
+
timeout 3600; <<この行を追加するとエラーになります
|
48
|
+
|
49
|
+
location /static {
|
50
|
+
|
51
|
+
alias /var/www/static;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
location / {
|
58
|
+
|
59
|
+
proxy_pass http://127.0.0.1:8000;
|
60
|
+
|
61
|
+
proxy_set_header Host $http_host;
|
62
|
+
|
63
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```nginxConf
|
76
|
+
|
77
|
+
user nginx;
|
78
|
+
|
79
|
+
worker_processes auto;
|
80
|
+
|
81
|
+
error_log /var/log/nginx/error.log;
|
82
|
+
|
83
|
+
pid /run/nginx.pid;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
|
88
|
+
|
89
|
+
include /usr/share/nginx/modules/*.conf;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
events {
|
94
|
+
|
95
|
+
worker_connections 1024;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
http {
|
102
|
+
|
103
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
104
|
+
|
105
|
+
'$status $body_bytes_sent "$http_referer" '
|
106
|
+
|
107
|
+
'"$http_user_agent" "$http_x_forwarded_for" $request_time';
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
access_log /var/log/nginx/access.log main;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
sendfile on;
|
116
|
+
|
117
|
+
tcp_nopush on;
|
118
|
+
|
119
|
+
tcp_nodelay on;
|
120
|
+
|
121
|
+
keepalive_timeout 3600;
|
122
|
+
|
123
|
+
proxy_connect_timeout 3600;
|
124
|
+
|
125
|
+
proxy_send_timeout 3600;
|
126
|
+
|
127
|
+
proxy_read_timeout 3600;
|
128
|
+
|
129
|
+
send_timeout 3600;
|
130
|
+
|
131
|
+
types_hash_max_size 2048;
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
include /etc/nginx/mime.types;
|
136
|
+
|
137
|
+
default_type application/octet-stream;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
142
|
+
|
143
|
+
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
144
|
+
|
145
|
+
# for more information.
|
146
|
+
|
147
|
+
include /etc/nginx/conf.d/*.conf;
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
server {
|
152
|
+
|
153
|
+
listen 80 default_server;
|
154
|
+
|
155
|
+
listen [::]:80 default_server;
|
156
|
+
|
157
|
+
server_name _;
|
158
|
+
|
159
|
+
root /usr/share/nginx/html;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# Load configuration files for the default server block.
|
164
|
+
|
165
|
+
include /etc/nginx/default.d/*.conf;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
location / {
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
error_page 404 /404.html;
|
176
|
+
|
177
|
+
location = /40x.html {
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
error_page 500 502 503 504 /50x.html;
|
184
|
+
|
185
|
+
location = /50x.html {
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
```
|