Rails环境部署问题?
我正在尝试在这里部署我的第一个 Rails 应用程序,但从昨晚开始我一直在做一些事情。我遇到了一些我无法解释的奇怪行为。
我正在运行 Rails、Apache、Phusion Passenger,目前还运行 SQLite 3。(我很快就会将其转移到 MySQL。)目前,它托管在运行 Ubuntu Server 11.04 (Natty) 的一个太小的 EC2 切片上。
当我在浏览器中访问 EC2 切片的地址时,我收到默认的 Rails 500 通知。不过,这就是奇怪的地方。当我尾部 /log/Production.log
时,我看到以下错误:
ActionView::Template::Error (SQLite3::SQLException: no such table: offers: SELECT "offers".* FROM "offers" WHERE (code = '') ORDER BY created_at desc LIMIT 25 OFFSET 0):
因此,我在 SQLite3 中手动打开开发数据库,并在其中看到了该表。然而,生产数据库没有该表。
好的,所以我在生产日志中记录了生产数据库的错误。应用程序必须在生产模式下运行,对吗?
这就是让我困惑的原因。首先,它在我的开发机器上以开发模式运行,并且在部署它时我没有更改任何文件。我也没有使用任何花哨的部署工具来部署它(这可能在我不知情的情况下改变了一些东西)——我只是做了一个简单的 git push 。
此外,我将以下内容添加到我的 httdp.conf VirtualHost 配置中:
RailsEnv development
另外,当我运行 Rails 控制台时,我可以获得以下信息:
irb(main):002:0> Rails.env
=> "development"
那么,应用程序确实应该在开发模式下运行,对吗?事实上,它似乎(部分地)认为是这样,对吧?
我真的不确定这里发生了什么,我真的很感谢一些专家的建议。
谢谢大家。
编辑 - 一些服务器稍后重新启动,现在当我尝试在浏览器中查看它时,它就会挂起。另外,当我尝试重新启动 Apache 时(因此服务器重新启动),Apache 似乎挂起,是相关问题还是完全不同的问题?
I'm trying to deploy my first Rails app here, and I've been stuck on something since last night. I'm encountering some weird behaviors I can't explain.
I'm running Rails, Apache, Phusion Passenger, and for the moment, SQLite 3. (I'll move that over to MySQL shortly.) Currently this is being hosted on a too-small EC2 slice running Ubuntu Server 11.04 (Natty).
When I visit the address of the EC2 slice in the browser, I get the default Rails 500 notice. Here's what's weird, though. When I tail /log/production.log
, I see the following error:
ActionView::Template::Error (SQLite3::SQLException: no such table: offers: SELECT "offers".* FROM "offers" WHERE (code = '') ORDER BY created_at desc LIMIT 25 OFFSET 0):
So, I manually opened up the development database in SQLite3, and saw that table in there. The production database, however, does not have that table.
OK, so I'm getting errors with the production database logged in the production log. The application has to be running in production mode, right?
That is what's throwing me. First of all, it's running in development mode on my development machine, and I didn't change any of the files when I deployed it. Neither did I use any fancy deployment tools to deploy it (which may have switched something without my knowledge) - I just did a simple git push
.
Furthermore, I added the following to my httdp.conf VirtualHost config:
RailsEnv development
Also, when I run rails console, I can get the following:
irb(main):002:0> Rails.env
=> "development"
So, the application really should be running in development mode, right? In fact, it seems to think (partially) that it is, right?
I'm really not sure what's happening here, and I'd really appreciate some expert advice.
Thanks everyone.
Edit - A few server reboots later, and now the thing just hangs when I try to view it in a browser. Also, Apache seems to hang when I try to restart it (hence the server reboots), related problem, or different problem altogether?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这对我来说并不是 100% 满意的答案,但我做了两件事,而且我认为我成功了。
首先,我重新安装了passenger Apache 模块。这可能有必要,也可能没有必要。
不过,这是一件大事:在我将这一行添加到 httpd.conf 以将 Rails 环境传递给 Passenger 后,我相信 Apache 重新启动不正确。 (相反,我相信我一生都在错误地重新启动 Apache!)
我试图以这种方式重新启动 Apache:
这一直对我有用(在编写 PHP 时),但它在这里不起作用。 Apache 只会在重新启动时停止。
然而,这工作得很好:
我必须询问服务器故障两者之间的显着区别是什么。
我希望这能帮助别人。
Well, this isn't a 100% satisfactory answer for me, but I did two things, and I think I got it working.
First, I re-installed the passenger Apache module. That may or may not have been necessary.
This was the big thing, though: after I had added the line to httpd.conf to pass the Rails Environment over to Passenger, I believe Apache restarted incorrectly. (Rather, I believe I've been restarting Apache incorrectly for my whole life!)
I was trying to restart Apache this way:
That has always worked for me (when programming PHP), but it simply wasn't working here. Apache would just stall on the restart.
This, however, works fine:
I'll have to ask Server Fault what the significant difference is between the two.
I hope that helps someone out.