开发者

Why does the server need to restart when a model file is updated?

I'd like to know why is there a need to restart the server (Mongrel/WEBrick) every time a model file is updated? I know开发者_开发百科 it doesn't get loaded in if you don't do it - but is there any documentation out there that would explain why it does so?

Thanks!


Development environments do not require you to restart the server if you change a model. They will reload the environment for each request if necessary.

Production environments are a different story. A Rails server (mongrel/passenger/webrick/etc) running in a production environment will only load your Rails environment once when the process is started. This takes a couple of seconds, as you might notice when starting the console which also loads your Rails environment. To avoid this overhead for each request the server will spawn a new thread from the loaded environment to handle each incoming request.

Because the server only responds to HTTP requests, and the usual signals. There's no good way to force an environment reload beyond always loading a fresh environment (like a development environment, or restarting the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜