Support for graceful shutdown

Aperta
#287 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
32/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c, r
Ambito
networking

Direzione di ricerca

Start with the httpuv server object and its connections callback, then review how server behavior is exposed at the R level. Trace the existing listener, HTTP, and WebSocket lifecycle before deciding where a shutdown state belongs. Done means existing connections can finish while new connections are rejected, with a usable R-level shutdown entry point.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

My motivation here is that to have some sort of graceful transition during Shiny deployments so that existing users don't immediately greyscreen. By this I mean that existing websocket/HTTP connections should continue to work but new connections cannot be made to the running server.

As an external example, the HTTP server from the Go standard library can be put into "shutdown" mode:

Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down.

Which sounds like the right approach to me. Waiting indefinitely is fine for our usecase, since SIGKILL can be used to terminate the process eventually if it exceeds some timeout. (This is how Kubernetes works by default.)

There is an upstream issue on libuv for a direct "stop listening" API that links to various supporting discussions, but it has not been implemented.

The libuv thread above suggests emulating "stop listening" support by having the connections callback just call uv_close() right after calling uv_accept() (as simply not calling uv_accept will accumulate connections in the kernel). I believe httpuv could do when a "shutdown" flag has been set on the server object, although I'm not sure how this ought to be exposed at the R level.

This is mildly related to #226.

Lingua principale
C
Stelle
252
Fork
87
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rstudio/httpuv

Tutte le issue di rstudio/httpuv

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.