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

質問編集履歴

3

config/unicorn.rbを追記

2021/05/05 06:36

投稿

fastman
fastman

スコア3

title CHANGED
File without changes
body CHANGED
@@ -62,7 +62,52 @@
62
62
  $ dig 【ドメイン名】
63
63
  # => 正しく出力される
64
64
  ```
65
+ - config/unicorn.rb
66
+ ```ruby
67
+ app_path = File.expand_path('../../../', __FILE__)
68
+
69
+ worker_processes 1
70
+
71
+ working_directory "#{app_path}/current"
72
+
73
+ pid "#{app_path}/shared/tmp/pids/unicorn.pid"
74
+
75
+ listen "#{app_path}/shared/tmp/sockets/unicorn.sock"
76
+
77
+ stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
78
+
79
+ stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
80
+
81
+
82
+ timeout 60
83
+
84
+ preload_app true
85
+ GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
86
+
87
+ check_client_connection false
88
+
89
+ run_once = true
90
+
91
+ before_fork do |server, worker|
92
+ defined?(ActiveRecord::Base) &&
93
+ ActiveRecord::Base.connection.disconnect!
94
+
65
- - unicornの起動
95
+ if run_once
96
+ run_once = false # prevent from firing again
66
- ```
97
+ end
98
+
99
+ old_pid = "#{server.config[:pid]}.oldbin"
100
+ if File.exist?(old_pid) && server.pid != old_pid
101
+ begin
102
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
103
+ Process.kill(sig, File.read(old_pid).to_i)
104
+ rescue Errno::ENOENT, Errno::ESRCH => e
105
+ logger.error e
106
+ end
107
+ end
108
+ end
109
+
110
+ after_fork do |_server, _worker|
67
- bundle exec unicorn_rails -c config/unicorn.rb -E production -D
111
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
112
+ end
68
113
  ```

2

unicornの起動について追加

2021/05/05 06:36

投稿

fastman
fastman

スコア3

title CHANGED
File without changes
body CHANGED
@@ -61,4 +61,8 @@
61
61
  ```
62
62
  $ dig 【ドメイン名】
63
63
  # => 正しく出力される
64
+ ```
65
+ - unicornの起動
66
+ ```
67
+ bundle exec unicorn_rails -c config/unicorn.rb -E production -D
64
68
  ```

1

不足追加

2021/05/04 06:49

投稿

fastman
fastman

スコア3

title CHANGED
File without changes
body CHANGED
@@ -55,4 +55,10 @@
55
55
  nginx
56
56
  ec2
57
57
  unicorn
58
- capistrano
58
+ capistrano
59
+
60
+ - リストIPアドレスからはアクセスできる
61
+ ```
62
+ $ dig 【ドメイン名】
63
+ # => 正しく出力される
64
+ ```