Giter Site home page Giter Site logo

graceful shutdown? about chi HOT 3 CLOSED

go-chi avatar go-chi commented on May 5, 2024
graceful shutdown?

from chi.

Comments (3)

pkieltyka avatar pkieltyka commented on May 5, 2024

@alinz well, chi's router implements http.Handler, so you can use any third party graceful shutdown package like https://github.com/tylerb/graceful or like we do in the Pressly API using goji's graceful package with chi: https://github.com/zenazn/goji/tree/master/graceful

once nice thing to trigger a ctx.Done via the cancelFunc from a context when a shutdown is called. I have a trick in imgry where I do this..

https://github.com/pressly/imgry/blob/master/cmd/imgry-server/main.go#L38-L41
https://github.com/pressly/imgry/blob/master/server/server.go#L95
https://github.com/pressly/imgry/blob/master/server/middleware.go#L16-L26

the above example works by having a server-wide context, and replace the context in the chain with this one by copying the urlparams first. I thought, maybe we could have a parent ctx on the router itself, but, didn't think of an elegant enough solution for it and too busy to find one since this works.

from chi.

alinz avatar alinz commented on May 5, 2024

Awesome! thanks!

from chi.

pkieltyka avatar pkieltyka commented on May 5, 2024

no prob. let's keep it open for a bit in case others have the same question.

from chi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.