質問編集履歴

3

config/unicorn.rbを追記

2021/05/05 06:36

投稿

fastman
fastman

スコア3

test CHANGED
File without changes
test CHANGED
@@ -126,10 +126,100 @@
126
126
 
127
127
  ```
128
128
 
129
+ - config/unicorn.rb
130
+
131
+ ```ruby
132
+
133
+ app_path = File.expand_path('../../../', __FILE__)
134
+
135
+
136
+
137
+ worker_processes 1
138
+
139
+
140
+
141
+ working_directory "#{app_path}/current"
142
+
143
+
144
+
145
+ pid "#{app_path}/shared/tmp/pids/unicorn.pid"
146
+
147
+
148
+
149
+ listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
150
+
151
+
152
+
153
+ stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
154
+
155
+
156
+
157
+ stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
158
+
159
+
160
+
161
+
162
+
163
+ timeout 60
164
+
165
+
166
+
167
+ preload_app true
168
+
169
+ GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
170
+
171
+
172
+
173
+ check_client_connection false
174
+
175
+
176
+
177
+ run_once = true
178
+
179
+
180
+
181
+ before_fork do |server, worker|
182
+
183
+ defined?(ActiveRecord::Base) &&
184
+
185
+ ActiveRecord::Base.connection.disconnect!
186
+
187
+
188
+
129
- - unicornの起動
189
+ if run_once
190
+
130
-
191
+ run_once = false # prevent from firing again
192
+
193
+ end
194
+
195
+
196
+
197
+ old_pid = "#{server.config[:pid]}.oldbin"
198
+
199
+ if File.exist?(old_pid) && server.pid != old_pid
200
+
201
+ begin
202
+
203
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
204
+
205
+ Process.kill(sig, File.read(old_pid).to_i)
206
+
207
+ rescue Errno::ENOENT, Errno::ESRCH => e
208
+
209
+ logger.error e
210
+
211
+ end
212
+
213
+ end
214
+
215
+ end
216
+
217
+
218
+
219
+ after_fork do |_server, _worker|
220
+
221
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
222
+
223
+ end
224
+
131
- ```
225
+ ```
132
-
133
- bundle exec unicorn_rails -c config/unicorn.rb -E production -D
134
-
135
- ```

2

unicornの起動について追加

2021/05/05 06:36

投稿

fastman
fastman

スコア3

test CHANGED
File without changes
test CHANGED
@@ -125,3 +125,11 @@
125
125
  # => 正しく出力される
126
126
 
127
127
  ```
128
+
129
+ - unicornの起動
130
+
131
+ ```
132
+
133
+ bundle exec unicorn_rails -c config/unicorn.rb -E production -D
134
+
135
+ ```

1

不足追加

2021/05/04 06:49

投稿

fastman
fastman

スコア3

test CHANGED
File without changes
test CHANGED
@@ -113,3 +113,15 @@
113
113
  unicorn
114
114
 
115
115
  capistrano
116
+
117
+
118
+
119
+ - リストIPアドレスからはアクセスできる
120
+
121
+ ```
122
+
123
+ $ dig 【ドメイン名】
124
+
125
+ # => 正しく出力される
126
+
127
+ ```