質問編集履歴

1

該当設定ファイルを追記致しました

2021/01/10 02:18

投稿

daifuku0515
daifuku0515

スコア3

test CHANGED
File without changes
test CHANGED
@@ -40,95 +40,189 @@
40
40
 
41
41
  ### 該当のソースコード
42
42
 
43
- 非常に長いので、冒頭の部分だけ載します。
44
-
45
- I, [2021-01-09T05:49:46.218162 #8844] INFO -- : Refreshing Gem list
46
-
47
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn.rb:80: [BUG] vm_get_cref: unreachable
48
-
49
- ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
50
-
51
-
52
-
53
- -- Control frame information -----------------------------------------------
54
-
55
- c:0008 p:0168 s:0047 e:000044 BLOCK /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn.rb:80
56
-
57
- c:0007 p:0040 s:0037 e:000036 BLOCK /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/bin/unicorn_rails:139
58
-
59
- c:0006 p:0098 s:0030 e:000027 METHOD /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:826
60
-
61
- c:0005 p:0079 s:0024 E:000cf0 METHOD /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:141
62
-
63
- c:0004 p:0228 s:0020 E:0019a0 TOP /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/bin/unicorn_rails:209 [FINISH]
64
-
65
- c:0003 p:---- s:0013 e:000012 CFUNC :load
66
-
67
- c:0002 p:0112 s:0008 E:0003c0 EVAL /home/daifuku/.rbenv/versions/3.0.0/bin/unicorn_rails:23 [FINISH]
68
-
69
- c:0001 p:0000 s:0003 E:001e30 (none) [FINISH]
70
-
71
-
72
-
73
- -- Ruby level backtrace information ----------------------------------------
74
-
75
- /home/daifuku/.rbenv/versions/3.0.0/bin/unicorn_rails:23:in `<main>'
76
-
77
- /home/daifuku/.rbenv/versions/3.0.0/bin/unicorn_rails:23:in `load'
78
-
79
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/bin/unicorn_rails:209:in `<top (required)>'
80
-
81
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:141:in `start'
82
-
83
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:826:in `build_app!'
84
-
85
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/bin/unicorn_rails:139:in `block in rails_builder'
86
-
87
- /home/daifuku/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/unicorn-5.8.0/lib/unicorn.rb:80:in `block in builder'
88
-
89
-
90
-
91
- -- C level backtrace information -------------------------------------------
92
-
93
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_vm_bugreport+0x783) [0x7f4f48b4abf3] vm_dump.c:758
94
-
95
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(bug_report_end+0x0) [0x7f4f4896c1a9] error.c:763
96
-
97
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_bug_without_die) error.c:763
98
-
99
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(die+0x0) [0x7f4f488df203] error.c:771
100
-
101
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_bug) error.c:773
102
-
103
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_get_ev_const+0x248) [0x7f4f48b21de8] vm_insnhelper.c:832
104
-
105
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_exec_core+0x136d) [0x7f4f48b3370d] vm_insnhelper.c:964
106
-
107
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_vm_exec+0x84e) [0x7f4f48b3878e] vm.c:2172
108
-
109
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(raise_load_if_failed+0x0) [0x7f4f489cad15] load.c:594
110
-
111
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_load_internal) load.c:654
112
-
113
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_f_load) load.c:726
114
-
115
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_call_cfunc_with_frame+0x103) [0x7f4f48b26e93] vm_insnhelper.c:2898
116
-
117
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_call_method_each_type+0xd5) [0x7f4f48b3ad25] vm_insnhelper.c:3388
118
-
119
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_call_method+0xe6) [0x7f4f48b3b316] vm_insnhelper.c:3506
120
-
121
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_sendish+0x95) [0x7f4f48b324f5] vm_insnhelper.c:4499
122
-
123
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(vm_exec_core) insns.def:789
124
-
125
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_vm_exec+0xc5) [0x7f4f48b38005] vm.c:2163
126
-
127
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(rb_ec_exec_node+0xd6) [0x7f4f48973676] eval.c:317
128
-
129
- /home/daifuku/.rbenv/versions/3.0.0/lib/libruby.so.3.0(ruby_run_node+0x55) [0x7f4f489791d5] eval.c:375
130
-
131
- /home/daifuku/.rbenv/versions/3.0.0/bin/ruby(main+0x5b) [0x40087b] ./main.c:50
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
+ ```