以生产模式本地

时间:2015-12-07 13:18:08

标签: ruby-on-rails ruby ruby-on-rails-3 concurrency thin

我们有一些并发问题,我想在我的机器上重现。在生产中我们有一个乘客实例在运行。为了获得并发请求,我尝试使用这样的瘦和线程选项启动rails应用程序( Rails 3.2 ):

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

我还运行RAILS_ENV=production bundle exec rake assets:precompile以获得生产中的所有内容。

但是,当我在浏览器中访问localhost:3000时,我会获得HTML的一部分(显示),但随后浏览器会在GET http://localhost:3000/ net::ERR_EMPTY_RESPONSE的情况下运行超时并停止加载页面。< / p>

当我使用Ctrl-C停止瘦身时,我多次收到以下消息:

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

任何人都有一个想法,为什么浏览器会超时,或者如何在瘦的本地计算机上运行并发请求?尝试像puma这样的其他服务器也没问题,但整个apache /乘客安装会太多。

更新

我在没有浏览器的情况下尝试过,只需要curl --verbose http://localhost:3000。第一次,我得到了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)

但是第二次运行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

不幸的是,没有错误写入精简输出或log/production.log

2 个答案:

答案 0 :(得分:0)

完全疯狂的推测猜测......但您是否在生产中启用了部分缓存,并且无法从本地环境访问缓存服务器(例如,memcache或redis)?它可能(???)解释为什么HTML只是部分渲染。

答案 1 :(得分:0)

您是否更新了配置,以便他们指向您所有的本地资源,而不是尝试访问生产资源?

我在这里想到的是,你的一个资源可能无法访问。还尝试在config / environments / production.rb

中减少要调试的日志级别