Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early binding for proxy port #30

Closed
dblock opened this issue Dec 10, 2012 · 4 comments
Closed

Early binding for proxy port #30

dblock opened this issue Dec 10, 2012 · 4 comments

Comments

@dblock
Copy link
Contributor

dblock commented Dec 10, 2012

I am not sure whether this is a feature request or I'm doing something wrong :)

Trying to put a thin server behind a proxy (code almost identical to one in this post or this repo).

What I am seeing is that the proxy binds to the external port only once it was able to open a connection to the server it's proxying to, which for my purposes is too late. What I am trying to do is to start accepting requests and fail those until the backend comes up. Can this be accomplished?

@igrigorik
Copy link
Owner

The thin example post is proxying to a local Unix socket.. so the connection time is zero-to-none.

Not sure how well this will work, but give it a try: wrap conn.server call into EM.next_tick {}. In theory, this should allow you to setup the callbacks and accept the connection, but defer the actual connection until next server tick..

If that doesn't work, then it's certainly doable.. but may require modifications to the current proxy code.

@dblock
Copy link
Contributor Author

dblock commented Dec 11, 2012

That worked. There was an additional difficulty needing to only next_tick until the server is up, otherwise I was ending up with an unresponsive system. I don't completely understand why.

I posted a gist in https://gist.github.com/4259205 - I'd really appreciate any comments/suggestions/improvements, maybe there's a cleaner way to achieve this?

I'll close this issue, thanks.

@dblock dblock closed this as completed Dec 11, 2012
@igrigorik
Copy link
Owner

Cool. re, gist: looks good.

@dblock
Copy link
Contributor Author

dblock commented Dec 11, 2012

Fyi, if anyone hits this page - I've used this in https://github.com/dblock/heroku-forward - it's a packaged implementation for beating the Heroku 60s boot timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants