每次更改 Rails 代码时,我都必须重新启动 Apache [英] I have to restart Apache every time I change my Rails code

查看:37
本文介绍了每次更改 Rails 代码时,我都必须重新启动 Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Apache 和Passenger 运行Rails 3.自从我从 Mongrel 切换到Passenger 后,我发现每次更改代码时都必须重新启动Apache.这是预期的行为吗?在开发中使用 Mongrel 是避免这个问题的唯一方法吗?

I'm running Rails 3 with Apache and Passenger. Ever since I switched from Mongrel to Passenger I find that I have to restart Apache every single time I change my code. Is this the intended behavior? Is the only way to avoid this problem to use Mongrel in development?

推荐答案

假设您必须重新启动 Apache,即使是模型/视图/控制器代码,您似乎已经设置了 Passenger 在生产环境中运行您的应用程序环境.您可以通过将 RailsEnv development 附加到您的虚拟主机来解决此问题.

Assuming you have to restart Apache even for model/view/controller code, it would seem as if you've set up Passenger to run your app in the production environment. You can fix this by appending RailsEnv development to your virtual host.

某些代码会要求您重新启动应用程序——例如 config/initializersvendor 中的任何内容.

Some code will require you to restart the app--examples of this is anything in config/initializers and vendor.

有一种方法可以只重启应用程序(而不是整个服务器),只需touch tmp/restart.txt.这将更新tmp/restart.txt 的时间戳,这将触发Passenger 重新启动应用程序.

There's a way to only restart the app (and not the entire server), which is simply touch tmp/restart.txt. This will update the timestamp of tmp/restart.txt, which will trigger Passenger to restart the app.

此外,您可以执行touch tmp/always_restart.txt.这将告诉乘客在每次页面加载时重新启动应用程序.如果您正在处理需要重新启动的部分(例如上面提到的示例),这会很有用.要停止自动重启,您必须删除该文件,如下所示:rm tmp/always_restart.txt.

Additionally, you can do touch tmp/always_restart.txt. This will tell Passenger to restart the app on every page load. This can be useful if you're working on sections that require restarts (such as the examples mentioned above). To stop the automatic restarting, you'll have to delete the file, like this: rm tmp/always_restart.txt.

这篇关于每次更改 Rails 代码时,我都必须重新启动 Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆