简体   繁体   English

Rails 服务器在开发模式下工作,但不在生产模式下

[英]Rails server works in dev mode but not in production mode

I have been building an app for a few months now, I had it hosted on heroku, and I started making changes to it for a while without pushing to heroku, just working on localhost.我已经构建了一个应用程序几个月了,我把它托管在 heroku 上,我开始对其进行一段时间的更改,而没有推送到 heroku,只是在本地主机上工作。 I went to push it to heroku and ran into an issue with the asset pipeline not liking a variable in an erb tag.我将其推送到 heroku 并遇到了资产管道不喜欢 erb 标签中的变量的问题。 I took it out to get the code pushed, and ran into a bigger issue.我把它拿出来推送代码,然后遇到了一个更大的问题。 Still, a 500 error but the logs now said:仍然,一个 500 错误,但日志现在说:

ActionView::Template::Error (FATAL:  Peer authentication failed for user "fullstack".

Now, in my research on this issue, I attempted several things, and here are some of my findings.现在,在我对这个问题的研究中,我尝试了几件事,以下是我的一些发现。

I did not change the storage.yml or database.yml files at all.我根本没有更改 storage.yml 或 database.yml 文件。 The production server is AWS s3 buckets, and they are connected to config.active_storage.service for both the production and development in the config/environments files.生产服务器是 AWS s3 存储桶,它们连接到 config.active_storage.service 用于 config/environments 文件中的生产和开发。

The production user in the database.yml is named fullstack. database.yml 中的生产用户名为 fullstack。 The development user does not have a username or password.开发用户没有用户名或密码。 I was able to reset the server with the original username and password, but when I change the production username and reset the server it says我能够使用原始用户名和密码重置服务器,但是当我更改生产用户名并重置服务器时,它说

PG::ConnectionBad: fe_sendauth: no password supplied

So I go into the terminal and check the owner of the fullstack database, a few things with that.所以我 go 进入终端并检查全栈数据库的所有者,一些事情。 First I check psql -l to see all databases, and I have a fullstack_test and a fullstack_development, but no fullstack_production, and I think that is normal since rails only generate the dev and test on creation.首先,我检查 psql -l 以查看所有数据库,我有一个 fullstack_test 和一个 fullstack_development,但没有 fullstack_production,我认为这是正常的,因为 rails 只在创建时生成开发和测试。 Those two are owned by my Ubuntu user, sethb.这两个归我的 Ubuntu 用户 sethb 所有。 I tried to create a fullstack_production database to see what would happen, and I get this error我试图创建一个 fullstack_production 数据库来看看会发生什么,我得到了这个错误

PG::ConnectionBad: FATAL:  Peer authentication failed for user "fullstack"

When I was researching this, people were saying to change a setting in my pg_hba.当我研究这个时,人们说要更改我的 pg_hba 中的设置。 I looked into mine and it already had set to: host all all all trust.我查看了我的,它已经设置为:托管所有所有信任。 I have been at this for about 20 hours at this point and I would love to hear if someone has an idea on how to fix this, I don't even know how to proceed with this honestly.在这一点上,我已经在这里待了大约 20 个小时,我很想听听是否有人对如何解决这个问题有想法,我什至不知道如何诚实地进行。 Any help would be very much appreciated.任何帮助将不胜感激。 I can also provide more info on any logs that I have had if it would help如果有帮助,我还可以提供有关我拥有的任何日志的更多信息

So an update to the story, a half way solution.所以更新故事,半途而废。 I was cloning the full project and aws, and when I went to push to heroku, someone helped me notice that I didn't have a node.js buildpack installed.我正在克隆完整的项目和 aws,当我推送到 heroku 时,有人帮我注意到我没有安装 node.js buildpack。 As soon as I did that and pushed the new version, it worked.一旦我这样做并推送了新版本,它就起作用了。 I tried rails s -e production, but that still throws a 500 error.我尝试了 rails s -e production,但这仍然会引发 500 错误。 This time it's saying application.css isn't present.这次它说的是 application.css 不存在。 But that is an issue I think someone has a solution for later.但这是一个问题,我认为有人稍后会有解决方案。 Either way, check your Heroku settings!无论哪种方式,请检查您的 Heroku 设置! Thank you谢谢

Seth B.赛斯·B。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM