简体   繁体   English

在本地生产模式下启动Rails服务器

[英]Start rails server in production mode local

we have some concurrency issues, that I'd like to reproduce on my machine. 我们有一些并发问题,我想在我的机器上重现。 On production we have a passenger instance running. 在生产中,我们有一个正在运行的乘客实例。 To get concurrent request, I tried to start the rails app ( Rails 3.2 ) with thin and a threaded option like this: 为了获得并发请求,我尝试使用瘦的和线程化的选项启动rails应用程序( Rails 3.2 ),如下所示:

bundle exec thin --threaded -p 3000 --threadpool-size 50 start -e production

I also ran RAILS_ENV=production bundle exec rake assets:precompile to get everything like in production. 我还运行了RAILS_ENV=production bundle exec rake assets:precompile以获取生产环境中的所有内容。

However, when I access localhost:3000 in my browser, I get part of the HTML (it displays), but then the browser runs into a timeout with GET http://localhost:3000/ net::ERR_EMPTY_RESPONSE and loading of the page stops. 但是,当我在浏览器中访问localhost:3000时,我得到了HTML的一部分(它显示了),但随后浏览器因GET http://localhost:3000/ net::ERR_EMPTY_RESPONSEGET http://localhost:3000/ net::ERR_EMPTY_RESPONSE并加载了页面停止。

When I stop thin with Ctrl-C, I get the following message multiple times: 当我用Ctrl-C停止时,我多次收到以下消息:

Unexpected error while processing request: Attempt to unlock a mutex which is not locked

Anybody an idea, why the browser gets a timeout, or how to get concurrent requests working on a local machine with thin? 有人知道为什么浏览器超时,或者如何使并发请求在精简的本地计算机上工作吗? It would also be no problem to try another server like puma, but a whole apache / passenger installation would be too much. 尝试使用其他服务器(如puma)也没有问题,但是整个apache / passenger安装会太多。

Update 更新

I tried it without the browser, and just do a curl --verbose http://localhost:3000 . 我在没有浏览器的情况下尝试了一下,只做了curl --verbose http://localhost:3000 The first time, I get the HTML back: 第一次,我得到了HTML:

* Rebuilt URL to: http://localhost:3000/
*   Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Content-Length: 88748
< X-UA-Compatible: IE=Edge,chrome=1
< ETag: "d16fa9f8e279774f09c2172988a6d5a6"
< Cache-Control: max-age=0, private, must-revalidate
< Set-Cookie: _session_id=c23af3cc254b66789b635edfefd4a120; path=/; HttpOnly
< X-Request-Id: 539b87c3916cf6733fc9e91a05c4f8e9
< X-Runtime: 0.488556
< Date: Mon, 07 Dec 2015 13:33:26 GMT
< X-Rack-Cache: miss
< Connection: keep-alive
< Server: thin
< 
<!DOCTYPE html>
... (more html)

But the second time I run the curl command, it times out: 但是第二次我运行curl命令时,它超时了:

* Rebuilt URL to: http://localhost:3000/
*   Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.43.0
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

Unfortunately, no errors are written to the thin's output or log/production.log . 不幸的是,没有任何错误写入瘦目录的输出或log/production.log

Completely wild speculative guess... but do you have partial caching enabled in production, and not able to reach the cache server (eg, memcache or redis) from your local environment? 完全是推测性的猜测...但是您是否在生产中启用了部分缓存,并且无法从本地环境访问缓存服务器(例如,memcache或redis)? It might (???) explain why the HTML only partly renders. 它可能(???)解释了为什么HTML仅部分呈现。

Did you update your config so that they point to all your local resources instead of trying to reach the production resources? 您是否更新了配置,以便它们指向您的所有本地资源,而不是尝试访问生产资源?

What I can think of happening here is that, one of your resource is probably un-reachable. 我可以想到的是,您的资源之一可能无法访问。 Also try to reduce the log level to debug in config/environments/production.rb 也尝试减少日志级别以在config / environments / production.rb中进行调试

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

相关问题 如何使用unicorn和配置文件在生产模式下启动rails服务器? - How to start rails server in production mode using unicorn and config file? Rails 服务器在开发模式下工作,但不在生产模式下 - Rails server works in dev mode but not in production mode Rails乘客服务器未在生产模式下运行 - Rails passenger server not running in production mode Rails 4-服务器在开发模式下工作,但不在生产模式下工作 - Rails 4 - server works in development mode, but not in production 在webrick服务器上的生产模式下运行rails - Running rails on a Production mode in webrick server 为什么当我在生产模式下启动瘦服务器时,找不到我的用户表,而在常规模式下却找到了? -滑轨3 - Why when I start thin server in production mode it can't find my users table, but it does in regular mode ? - Rails 3 尝试在生产环境中启动Rails服务器 - Trying to start rails server in production environment Rails服务器未在生产中启动 - Rails server doesn't start in production 无法在生产服务器上启动rails 4控制台 - Cannot start rails 4 console on production server 为什么WEBrick服务器在生产模式下比在开发模式下更快? +滑轨 - Why WEBrick server is faster in production mode rather in development mode? + Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM