feat(app): pass context to start process

This commit is contained in:
2023-10-19 20:05:59 +02:00
parent 4d064de164
commit efb8ba8b99
13 changed files with 46 additions and 35 deletions

View File

@ -1,7 +1,8 @@
package http
import (
"io/ioutil"
"context"
"io"
"net/http"
"sync"
@ -40,7 +41,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.router.ServeHTTP(w, r)
}
func (h *Handler) Load(bdle bundle.Bundle) error {
func (h *Handler) Load(ctx context.Context, bdle bundle.Bundle) error {
h.mutex.Lock()
defer h.mutex.Unlock()
@ -49,7 +50,7 @@ func (h *Handler) Load(bdle bundle.Bundle) error {
return errors.Wrap(err, "could not open server main script")
}
mainScript, err := ioutil.ReadAll(file)
mainScript, err := io.ReadAll(file)
if err != nil {
return errors.Wrap(err, "could not read server main script")
}
@ -68,7 +69,7 @@ func (h *Handler) Load(bdle bundle.Bundle) error {
h.server.Stop()
}
if err := server.Start(); err != nil {
if err := server.Start(ctx); err != nil {
return errors.WithStack(err)
}