labstack / echox

Echo cookbook and website
https://echo.labstack.com
MIT License
408 stars 285 forks source link

Refactor graceful shutdown example to work better with returned errors and background processes handling #189

Closed aldas closed 3 years ago

aldas commented 3 years ago

Reason to switching where server is started with signal waiting is that - with server we need to handle errors and sometimes do work with things that were opened/started before Echo started serving requests. If that flow is in main flow (outside of goroutine) - it is easier to handle that as e.Start() is anyway blocking until server stops and steps we want to do are after that

also moved all graceful logic to method as it is then more copy/paste friendly

NB: this logic still kills program when timeout for graceful shutdown is exceeded

aldas commented 3 years ago

forgot nuance that e.Start returns on e.Shutdown call