简体   繁体   中英

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:

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.

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.

When I stop thin with Ctrl-C, I get the following message multiple times:

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.

Update

I tried it without the browser, and just do a curl --verbose http://localhost:3000 . The first time, I get the HTML back:

* 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:

* 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 .

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? It might (???) explain why the HTML only partly renders.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM