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

Graceful server reloading #49

Open
shazow opened this issue Dec 14, 2014 · 4 comments
Open

Graceful server reloading #49

shazow opened this issue Dec 14, 2014 · 4 comments

Comments

@shazow
Copy link
Owner

shazow commented Dec 14, 2014

So many new features, sad to drop all connections to restart the server.

There are lots of posts about how to do this for http servers, but not sure how much more complicated it would be to do for an ssh tcp socket. Any investigating/resources appreciated.

Relevant links:

These seem to work by keeping two processes open until the old connections finish. This won't work for upgrading existing connections.

I'd also entertain a failover proxy frontend but I suspect that might not be possible without breaking ssh-chat into two big chunks (one of which could not be gracefully reloaded).

Another possibility is if there was some ssh protocol to request the client to reconnect.

@film42
Copy link

film42 commented Dec 15, 2014

These might generate some ideas:

  1. http://unix.stackexchange.com/questions/27636/how-does-ssh-connection-survive-a-network-restart
  2. http://www.cyberciti.biz/faq/if-sshd-is-restart-will-any-connections-be-disconnected/

Edit: They're just TCP sockets at the end of the day, so handling them like an HTTP server with sockets should be the same, right?

@mrfabbri
Copy link

DISCLAIMER: very very beginner Go level here, so I may have totally misinterpreted/mystified things, still the project is neat and the problem (graceful restart with persistent connections) is interesting.

Basically, both rcrwoley/goagain and facebookgo/grace provide same way to recover Listener connections from the restarted process (via a clever use of environment variables for passing the number/file descriptors of active listener connections, and then getting back the net connection from the file descriptor).

I guess a similar approach can be replicated on the file descriptors of the active connections but will prove slightly more complicated than with just Listener connection(s) (Accept() makes a very natural point where to break/restart the service and almost no state is carried across restart):

  • some state to rebuild clients (from connection file descriptors) should be saved/serialised somewhere;
  • client.handleChannels() should be "restart-wise" and handle the restart gracefully (stopping at the "right" point / saving info for restart).

Well, maybe this would just turn out an "ad-hoc, informally specified, implementation of half of a failover proxy frontend".

@persontwo
Copy link

Maybe a small proxy could be written in Erlang? I dunno, I've just heard people talk about hot code reloading in Erlang.

@persontwo
Copy link

There's a thread on HN today about graceful server restart with Go: https://news.ycombinator.com/item?id=8772636. Might be of interest to you.

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

No branches or pull requests

4 participants