Rails到heroku部署问题

时间:2019-09-03 23:38:09

标签: ruby-on-rails heroku

我尝试将Rails应用程序部署到heroku。我在日志中遇到问题。

2019-09-05T21:30:24.764421 + 00:00 app [web.1]:D,[2019-09-05T21:30:24.764290#10]调试-:[3adcd749-6637-4790-8b0d -dab833c46c47] [1m [36mUser Create(16.1ms)[0m [1m [32mINSERT INTO“ users”(“ name”,“ email”,“ note”,“ created_at”,“ updated_at”)值($ 1,$ 2,$ 3 ,$ 4,$ 5)返回“ id” [0m [[“ name”,“”],[“ email”,“”],[“ note”,“”],[“ created_at”,“ 2019-09-05 21:30:24.745537“],[” updated_at“,” 2019-09-05 21:30:24.745537“]] 2019-09-05T21:30:24.766999 + 00:00 app [web.1]:D,[2019-09-05T21:30:24.766917#10]调试-:[3adcd749-6637-4790-8b0d-dab833c46c47] [1m [35m(2.0ms)[0m [1m [35mCOMMIT [0m 2019-09-05T21:30:24.771504 + 00:00 app [web.1]:我,[2019-09-05T21:30:24.771419#10] INFO-:[3adcd749-6637-4790-8b0d-dab833c46c47]在161毫秒内完成500个内部服务器错误(ActiveRecord:47.8毫秒) 2019-09-05T21:30:24.772177 + 00:00 app [web.1]:F,[2019-09-05T21:30:24.772096#10]致命-:[3adcd749-6637-4790-8b0d-dab833c46c47]
2019-09-05T21:30:24.772242 + 00:00 app [web.1]:F,[2019-09-05T21:30:24.772179#10]致命-:[3adcd749-6637-4790-8b0d-dab833c46c47] Redis :: CannotConnectError(在127.0.0.1:6379(Errno :: ECONNREFUSED)上连接到Redis时出错): 2019-09-05T21:30:24.772293 + 00:00 app [web.1]:F,[2019-09-05T21:30:24.772241#10]致命-:[3adcd749-6637-4790-8b0d-dab833c46c47]
2019-09-05T21:30:24.772375 + 00:00 app [web.1]:F,[2019-09-05T21:30:24.772316#10]致命-:[3adcd749-6637-4790-8b0d-dab833c46c47] app / controllers / users_controller.rb:25:in block in create' 2019-09-05T21:30:24.772377+00:00 app[web.1]: [3adcd749-6637-4790-8b0d-dab833c46c47] app/controllers/users_controller.rb:23:in create' 2019-09-05T21:30:24.727793 + 00:00 heroku [router]:at = info method = POST path =“ / users” host = mailme-reminder.herokuapp.com request_id = 3adcd749-6637-4790-8b0d-dab833c46c47 fwd =“ 189.159.252.164” dyno = web.1 connect = 1ms服务= 178ms状态= 500字节= 1827协议= https 2019-09-05T21:30:24.913280 + 00:00 heroku [router]:at = info method = GET path =“ / favicon.ico” host = mailme-reminder.herokuapp.com request_id = df1321b0-44d2-46ef-9015 -45a7f2fc8c38 fwd =“ 189.159.252.164” dyno = web.1 connect = 1ms服务= 4ms状态= 304字节= 48协议= https 2019-09-05T21:31:09.129802 + 00:00 app [web.1]:我,[2019-09-05T21:31:09.129668#10] INFO-:[17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643]于2019-09-05 21:31:09 +0000为189.159.252.164开始获取“ /” 2019-09-05T21:31:09.131458 + 00:00 app [web.1]:我,[2019-09-05T21:31:09.131337#10] INFO-:[17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643]由UsersController#new处理为HTML 2019-09-05T21:31:09.138108 + 00:00 app [web.1]:我,[2019-09-05T21:31:09.138004#10] INFO-:[17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643]在布局/应用程序中呈现users / new.html.erb 2019-09-05T21:31:09.142089 + 00:00 app [web.1]:我,[2019-09-05T21:31:09.142006#10] INFO-:[17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643]在布局/应用程序中呈现的users / new.html.erb(3.8ms) 2019-09-05T21:31:09.144723 + 00:00 app [web.1]:我,[2019-09-05T21:31:09.144626#10] INFO-:[17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643]在13毫秒内完成200 OK(查看:9.4毫秒| ActiveRecord:0.0毫秒) 2019-09-05T21:31:09.101818 + 00:00 heroku [router]:at = info method = GET path =“ /” host = mailme-reminder.herokuapp.com request_id = 17ce6b70-1cd1-4b7e-b7b8-2a8b79f09643 fwd =“ 189.159.252.164” dyno = web.1 connect = 1ms服务= 19ms状态= 200字节= 5496协议= https 2019-09-05T21:31:26.058494 + 00:00 heroku [router]:at = info method = POST path =“ / users” host = mailme-reminder.herokuapp.com request_id = 63bbddba-107e-47b5-a0ee-ca8da83a6b0e fwd =“ 189.159.252.164” dyno = web.1 connect = 1ms服务= 26ms状态= 500字节= 1827协议= https 2019-09-05T21:31:26.085304 + 00:00 app [web.1]:我,[2019-09-05T21:31:26.085200#14] INFO-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]在2019-09-05 21:31:26 +0000为189.159.252.164开始发布POST“ / users” 2019-09-05T21:31:26.086465 + 00:00 app [web.1]:我,[2019-09-05T21:31:26.086388#14] INFO-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]由UsersController#create处理为HTML 2019-09-05T21:31:26.086570 + 00:00 app [web.1]:我,[2019-09-05T21:31:26.086505#14] INFO-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]参数:{“ utf8” =>“✓”,“ authenticity_token” =>“ DNicK64JMa2ApcaSeYrP84zdeZe7hDYc2HZktB0ObXp4IVmCobV4KJQnZ9UazBiROfn6sE / jsCredCh6HzMgwg =”“”“”“”“ com“,” date_and_time“ =>” 2019/09/05 17:00“,” note“ =>”检查“},”提交“ =>”提醒我“} 2019-09-05T21:31:26.092268 + 00:00 app [web.1]:D,[2019-09-05T21:31:26.092172#14]调试-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m [35m(1.0ms)[0m [1m [35mBEGIN [0m 2019-09-05T21:31:26.096930 + 00:00 app [web.1]:D,[2019-09-05T21:31:26.096826#14]调试-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m [36mUser Create(1.8ms)[0m [1m [32mINSERT INTO“ users”(“ name”,“ email”,“ note”,“ date_and_time”,“ created_at”,“ updated_at”)值($ 1,$ 2, $ 3,$ 4,$ 5,$ 6)返回“ id” [0m [[“ name”,“ Michael”],[“ email”,“ example_email@example.com”],[“ note”,“ Check”],[ “ date_and_time”,“ 2019-09-05 22:00:00”],[“ created_at”,“ 2019-09-05 21:31:26.092480”],[“ updated_at”,“ 2019-09-05 21: 31:26.092480“]] 2019-09-05T21:31:26.099330 + 00:00 app [web.1]:D,[2019-09-05T21:31:26.099250#14]调试-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e] [1m [35m(2.0ms)[0m [1m [35mCOMMIT [0m 2019-09-05T21:31:26.102570 + 00:00 app [web.1]:我,[2019-09-05T21:31:26.102493#14] INFO-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]在16毫秒内完成500个内部服务器错误(ActiveRecord:4.8毫秒) 2019-09-05T21:31:26.103205 + 00:00 app [web.1]:F,[2019-09-05T21:31:26.103127#14] FATAL-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]
2019-09-05T21:31:26.103267 + 00:00 app [web.1]:F,[2019-09-05T21:31:26.103206#14] FATAL-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e] Redis :: CannotConnectError(在127.0.0.1:6379(Errno :: ECONNREFUSED)上连接到Redis时出错): 2019-09-05T21:31:26.103318 + 00:00 app [web.1]:F,[2019-09-05T21:31:26.103263#14]致命-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e]
2019-09-05T21:31:26.103376 + 00:00 app [web.1]:F,[2019-09-05T21:31:26.103323#14] FATAL-:[63bbddba-107e-47b5-a0ee-ca8da83a6b0e] app / controllers / users_controller.rb:25:in block in create' 2019-09-05T21:31:26.103377+00:00 app[web.1]: [63bbddba-107e-47b5-a0ee-ca8da83a6b0e] app/controllers/users_controller.rb:23:in create'

2 个答案:

答案 0 :(得分:0)

如果您实际上并没有使用Active Storage,请在Config> Environments> production.rb中查找以下行;

# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local

只需注释掉config.active_storage.service = :local,使其看起来像这样:

# Store uploaded files on the local file system (see config/storage.yml for options)
# config.active_storage.service = :local

或者,完全删除这两行。

然后,它在Heroku上应该可以正常工作。

答案 1 :(得分:0)

Heroku不支持您的情况,您必须使用s3,如他们在文档https://devcenter.heroku.com/articles/active-storage-on-heroku中提到的那样,否则实例重启或部署新版本后,您将最终丢失图像。

  

在部署应用程序或自动重启(每24小时一次)后,文件将消失。

没有其他更好的选择,您可以:

  1. 继续使用heroku作为服务器,使用s3作为文件存储(免费套餐不收费,只是提醒您稍后将其关闭)
  2. 将所有内容移至AWS,因此您不必使用2个提供程序。