質問編集履歴
1
該当設定ファイルを追記致しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,95 +40,189 @@
|
|
40
40
|
|
41
41
|
### 該当のソースコード
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
c
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
43
|
+
【追記】1/10
|
44
|
+
|
45
|
+
設定したファイルのソースコードを載せます。アプリ名はhogeとしています。
|
46
|
+
|
47
|
+
またそれぞれのファイルについては、ls -lを実行し、以下にあることを確認済み
|
48
|
+
|
49
|
+
```ここに言語を入力
|
50
|
+
|
51
|
+
[daifuku@ip-10-0-1-212 config]$ pwd
|
52
|
+
|
53
|
+
/var/www/rails/hoge/config
|
54
|
+
|
55
|
+
[daifuku@ip-10-0-1-212 config]$ ls -l
|
56
|
+
|
57
|
+
-rw-rw-r-- 1 daifuku daifuku 939 1月 10 01:37 unicorn.conf.rb
|
58
|
+
|
59
|
+
-rw-rw-r-- 1 daifuku daifuku 1772 1月 9 01:08 database.yml
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
[daifuku@ip-10-0-1-212 conf.d]$ pwd
|
64
|
+
|
65
|
+
/etc/nginx/conf.d
|
66
|
+
|
67
|
+
[daifuku@ip-10-0-1-212 conf.d]$ ls -l
|
68
|
+
|
69
|
+
-rw-r--r-- 1 root root 710 1月 5 23:08 hoge.conf
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
unicorn.conf.rb
|
76
|
+
|
77
|
+
```ここに言語を入力
|
78
|
+
|
79
|
+
$worker = 2
|
80
|
+
|
81
|
+
$timeout = 30
|
82
|
+
|
83
|
+
$app_dir = "/var/www/rails/hoge" #自分のアプリケーション名
|
84
|
+
|
85
|
+
$listen = File.expand_path 'tmp/sockets/.unicorn.sock', $app_dir
|
86
|
+
|
87
|
+
$pid = File.expand_path 'tmp/pids/unicorn.pid', $app_dir
|
88
|
+
|
89
|
+
$std_log = File.expand_path 'log/unicorn.log', $app_dir
|
90
|
+
|
91
|
+
# set config
|
92
|
+
|
93
|
+
worker_processes $worker
|
94
|
+
|
95
|
+
working_directory $app_dir
|
96
|
+
|
97
|
+
stderr_path $std_log
|
98
|
+
|
99
|
+
stdout_path $std_log
|
100
|
+
|
101
|
+
timeout $timeout
|
102
|
+
|
103
|
+
listen $listen
|
104
|
+
|
105
|
+
pid $pid
|
106
|
+
|
107
|
+
# loading booster
|
108
|
+
|
109
|
+
preload_app true
|
110
|
+
|
111
|
+
# before starting processes
|
112
|
+
|
113
|
+
before_fork do |server, worker|
|
114
|
+
|
115
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
116
|
+
|
117
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
118
|
+
|
119
|
+
if old_pid != server.pid
|
120
|
+
|
121
|
+
begin
|
122
|
+
|
123
|
+
Process.kill "QUIT", File.read(old_pid).to_i
|
124
|
+
|
125
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
# after finishing processes
|
134
|
+
|
135
|
+
after_fork do |server, worker|
|
136
|
+
|
137
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
```
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
hoge.conf
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
error_log /var/www/rails/hoge/log/nginx.error.log;
|
154
|
+
|
155
|
+
access_log /var/www/rails/hoge/log/nginx.access.log;
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
client_max_body_size 2G;
|
160
|
+
|
161
|
+
upstream app_server {
|
162
|
+
|
163
|
+
server unix:/var/www/rails/hoge/tmp/sockets/.unicorn.sock fail_timeout=0;
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
server {
|
170
|
+
|
171
|
+
listen 80;
|
172
|
+
|
173
|
+
server_name 123.456.789.012(実際のIPとは異なります);
|
174
|
+
|
175
|
+
keepalive_timeout 5;
|
176
|
+
|
177
|
+
root /var/www/rails/hoge/public;
|
178
|
+
|
179
|
+
try_files $uri/index.html $uri.html $uri @app;
|
180
|
+
|
181
|
+
location @app {
|
182
|
+
|
183
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
184
|
+
|
185
|
+
proxy_set_header Host $http_host;
|
186
|
+
|
187
|
+
proxy_redirect off;
|
188
|
+
|
189
|
+
proxy_pass http://app_server;
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
error_page 500 502 503 504 /500.html;
|
196
|
+
|
197
|
+
location = /500.html {
|
198
|
+
|
199
|
+
root /var/www/rails/hoge/public;
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
database.yml
|
210
|
+
|
211
|
+
```ここに言語を入力
|
212
|
+
|
213
|
+
production:
|
214
|
+
|
215
|
+
<<: *default
|
216
|
+
|
217
|
+
database: hoge_production
|
218
|
+
|
219
|
+
username: root
|
220
|
+
|
221
|
+
password: 【空欄ではログインできなかったので、パスワードが入っています。唯一ここが記事とは違う箇所です】
|
222
|
+
|
223
|
+
```
|
224
|
+
|
225
|
+
|
132
226
|
|
133
227
|
|
134
228
|
|
@@ -157,3 +251,23 @@
|
|
157
251
|
・MySQL Ver 14.14 Distrib 5.7.32
|
158
252
|
|
159
253
|
・nginx version: nginx/1.16.1
|
254
|
+
|
255
|
+
・nginx,unicornのプロセス状態は以下のコマンドで確認しました。
|
256
|
+
|
257
|
+
```ここに言語を入力
|
258
|
+
|
259
|
+
[daifuku@ip-10-0-1-212 hoge]$ ps -ax |grep nginx
|
260
|
+
|
261
|
+
3349 ? Ss 0:00 nginx: master process /usr/sbin/nginx
|
262
|
+
|
263
|
+
19233 ? S 0:00 nginx: worker process
|
264
|
+
|
265
|
+
19519 pts/0 S+ 0:00 grep --color=auto nginx
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
[daifuku@ip-10-0-1-212 hoge]$ ps -ax |grep unicorn | grep -v grep
|
270
|
+
|
271
|
+
[daifuku@ip-10-0-1-212 hoge]$ 【何も表示されない】
|
272
|
+
|
273
|
+
```
|