質問編集履歴

4

環境を追加

2023/04/06 07:00

投稿

michikusa-mc
michikusa-mc

スコア27

test CHANGED
File without changes
test CHANGED
@@ -210,6 +210,7 @@
210
210
  - Rails 7.0.4
211
211
  - サーバー Render
212
212
  - gitリポジトリ github
213
+ - SQL sqlite3
213
214
 
214
215
  あともう少し、というところでエラーになっています。
215
216
  本当に困っています。

3

コード追加

2023/04/05 08:42

投稿

michikusa-mc
michikusa-mc

スコア27

test CHANGED
File without changes
test CHANGED
@@ -14,6 +14,189 @@
14
14
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/a5b378f5-c815-4073-ad27-20d1f24e76a6.png)
15
15
  二つ目・403エラー
16
16
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/43df4681-6ce7-40c9-9071-96f7939f667d.png)
17
+
18
+ ### Railsプロジェクトのコード
19
+ config/puma.rb
20
+ ```ruby
21
+ # Puma can serve each request in a thread from an internal thread pool.
22
+ # The `threads` method setting takes two numbers: a minimum and maximum.
23
+ # Any libraries that use thread pools should be configured to match
24
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
25
+ # and maximum; this matches the default thread size of Active Record.
26
+ #
27
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
28
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
29
+ threads min_threads_count, max_threads_count
30
+
31
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
32
+ # terminating a worker in development environments.
33
+ #
34
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
35
+
36
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
37
+ #
38
+ port ENV.fetch("PORT") { 3000 }
39
+
40
+ # Specifies the `environment` that Puma will run in.
41
+ #
42
+ environment ENV.fetch("RAILS_ENV") { "development" }
43
+
44
+ # Specifies the `pidfile` that Puma will use.
45
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
46
+
47
+ # Specifies the number of `workers` to boot in clustered mode.
48
+ # Workers are forked web server processes. If using threads and workers together
49
+ # the concurrency of the application would be max `threads` * `workers`.
50
+ # Workers do not work on JRuby or Windows (both of which do not support
51
+ # processes).
52
+ #
53
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
54
+
55
+ # Use the `preload_app!` method when specifying a `workers` number.
56
+ # This directive tells Puma to first boot the application and load code
57
+ # before forking the application. This takes advantage of Copy On Write
58
+ # process behavior so workers use less memory.
59
+ #
60
+ preload_app!
61
+
62
+ # Allow puma to be restarted by `bin/rails restart` command.
63
+ plugin :tmp_restart
64
+
65
+ ```
66
+ config/environments/production.rb
67
+ ```ruby
68
+ require "active_support/core_ext/integer/time"
69
+
70
+ Rails.application.configure do
71
+ # Settings specified here will take precedence over those in config/application.rb.
72
+
73
+ # Code is not reloaded between requests.
74
+ config.cache_classes = true
75
+
76
+ # Eager load code on boot. This eager loads most of Rails and
77
+ # your application in memory, allowing both threaded web servers
78
+ # and those relying on copy on write to perform better.
79
+ # Rake tasks automatically ignore this option for performance.
80
+ config.eager_load = true
81
+
82
+ # Full error reports are disabled and caching is turned on.
83
+ config.consider_all_requests_local = false
84
+ config.action_controller.perform_caching = true
85
+
86
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
87
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
88
+ # config.require_master_key = true
89
+
90
+ # Disable serving static files from the `/public` folder by default since
91
+ # Apache or NGINX already handles this.
92
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
93
+
94
+ # Compress CSS using a preprocessor.
95
+ # config.assets.css_compressor = :sass
96
+
97
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
98
+ config.assets.compile = false
99
+
100
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
101
+ # config.asset_host = "http://assets.example.com"
102
+
103
+ # Specifies the header that your server uses for sending files.
104
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
105
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
106
+
107
+ # Store uploaded files on the local file system (see config/storage.yml for options).
108
+ config.active_storage.service = :local
109
+
110
+ # Mount Action Cable outside main process or domain.
111
+ # config.action_cable.mount_path = nil
112
+ # config.action_cable.url = "wss://example.com/cable"
113
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
114
+
115
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
116
+ # config.force_ssl = true
117
+
118
+ # Include generic and useful information about system operation, but avoid logging too much
119
+ # information to avoid inadvertent exposure of personally identifiable information (PII).
120
+ config.log_level = :info
121
+
122
+ # Prepend all log lines with the following tags.
123
+ config.log_tags = [ :request_id ]
124
+
125
+ # Use a different cache store in production.
126
+ # config.cache_store = :mem_cache_store
127
+
128
+ # Use a real queuing backend for Active Job (and separate queues per environment).
129
+ # config.active_job.queue_adapter = :resque
130
+ # config.active_job.queue_name_prefix = "sns_production"
131
+
132
+ config.action_mailer.perform_caching = false
133
+
134
+ # Ignore bad email addresses and do not raise email delivery errors.
135
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
136
+ # config.action_mailer.raise_delivery_errors = false
137
+
138
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
139
+ # the I18n.default_locale when a translation cannot be found).
140
+ config.i18n.fallbacks = true
141
+
142
+ # Don't log any deprecations.
143
+ config.active_support.report_deprecations = false
144
+
145
+ # Use default logging formatter so that PID and timestamp are not suppressed.
146
+ config.log_formatter = ::Logger::Formatter.new
147
+
148
+ # Use a different logger for distributed setups.
149
+ # require "syslog/logger"
150
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
151
+
152
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
153
+ logger = ActiveSupport::Logger.new(STDOUT)
154
+ logger.formatter = config.log_formatter
155
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
156
+ end
157
+
158
+ # Do not dump schema after migrations.
159
+ config.active_record.dump_schema_after_migration = false
160
+
161
+ config.exceptions_app = self.routes
162
+
163
+ end
164
+
165
+ ```
166
+ bin/render-build.sh
167
+ ```sh
168
+ set -o errexit
169
+
170
+ bundle install
171
+ yarn install
172
+ yarn build
173
+ bundle exec rake assets:precompile
174
+ bundle exec ridgepole -c config/database.yml -E production --apply -f db/schemas/Schemafile
175
+ ```
176
+ render.yaml
177
+ ```yaml
178
+ databases:
179
+ - name: ChisanChishou
180
+ databaseName: rails7_sample_staging
181
+ user: michikusamichiya
182
+ region: singapore
183
+
184
+ services:
185
+ - type: web
186
+ name: rails7-sample-staging
187
+ env: ruby
188
+ region: singapore
189
+ plan: free
190
+ buildCommand: "./bin/render-build.sh"
191
+ startCommand: "bundle exec puma -C config/puma.rb"
192
+ envVars:
193
+ - key: DATABASE_URL
194
+ fromDatabase:
195
+ name: rails7_sample_staging
196
+ property: connectionString
197
+ - key: RAILS_MASTER_KEY
198
+ sync: false
199
+ ```
17
200
 
18
201
  ### 試したこと
19
202
 

2

書式の改善

2023/04/05 07:34

投稿

michikusa-mc
michikusa-mc

スコア27

test CHANGED
File without changes
test CHANGED
@@ -1,21 +1,33 @@
1
- !!!!!追記まし。「追記:」をご覧くださ。!!!!!
1
+ ### 実現したいこと
2
2
 
3
- 最近、RenderサーバーにRailsアプリをデプたのですが、デプロイしたサーバにアクセスすると502エラーが発生します
3
+ RailsプロジェクトをRenderサーバーにアプロードした。
4
- なぜでょうか?![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/209c1811-3853-4674-a123-bc6a12434679.png)
4
+ そのサーバーのURLにアクセスたら、Railsプロジェクトが
5
+ 表示されるようにしたいです。
5
6
 
7
+ ### 前提
6
- にデプロイが失敗した、というわけでもなさそうなのですが...
8
+ RailsプロジェクトをRender.comにデプロイしまし
9
+ しかし、そのサーバのURLにアクセスすると502エラー
10
+ または403エラーが発生します。
11
+
12
+ ### 発生している問題・エラーメッセージ
13
+ 一つ目・503エラー
14
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/a5b378f5-c815-4073-ad27-20d1f24e76a6.png)
15
+ 二つ目・403エラー
16
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/43df4681-6ce7-40c9-9071-96f7939f667d.png)
17
+
7
18
  ### 試したこと
8
- ---
9
- - 別ブラウザでのアクセス(Edge、Chrome、Firefox)
10
19
 
11
- ### 環境
20
+ - リスト別ブラウザでのアクセス(Microsoft Edge、Google Chrome Mozilla Firefox)
12
- サーバー:render.com
21
+ - サーバー再起動
13
- データベース:sqlite3
22
+ - pushし直し
14
- プログラミング言語:フレームワーク:ruby3.1.3、rails 7.0.4
15
23
 
24
+ ### 補足情報(FW/ツールのバージョンなど)
25
+ 環境は以下の通りです。
26
+ - Ruby 3.1.3
27
+ - Rails 7.0.4
28
+ - サーバー Render
29
+ - gitリポジトリ github
30
+
16
- サーバーにデプロイはできたよなのでただ単にアクセス権限がない、というこのでしょうか?
31
+ あとも少し、というろでエラーにっています。
32
+ 本当に困っています。
17
33
  ご回答宜しくお願い致します。
18
-
19
- 追記:
20
- 今度は、エラーが403になりました。
21
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/3d7c18a9-2f8d-4713-9df8-543c56a3ff00.png)

1

エラーが急に変わったので変更しました

2023/04/05 04:59

投稿

michikusa-mc
michikusa-mc

スコア27

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,5 @@
1
+ !!!!!追記しました。「追記:」をご覧ください。!!!!!
2
+
1
3
  最近、RenderサーバーにRailsアプリをデプロイしたのですが、デプロイしたサーバにアクセスすると502エラーが発生します。
2
4
  なぜでしょうか?![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/209c1811-3853-4674-a123-bc6a12434679.png)
3
5
 
@@ -13,3 +15,7 @@
13
15
 
14
16
  サーバーにデプロイはできたようなので、ただ単にアクセス権限がない、ということなのでしょうか?
15
17
  ご回答宜しくお願い致します。
18
+
19
+ 追記:
20
+ 今度は、エラーが403になりました。
21
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2023-04-05/3d7c18a9-2f8d-4713-9df8-543c56a3ff00.png)